ELinks 0.18.0
file.h File Reference
#include <stdio.h>
#include <sys/stat.h>
#include "intl/libintl.h"
#include "util/conv.h"
#include "util/string.h"
Include dependency graph for file.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  directory_entry
 Data read about an entry in a directory. More...

Functions

struct directory_entryget_directory_entries (char *dirname, int get_hidden_files)
 First information such as permissions is gathered for each directory entry.
int file_exists (const char *filename)
int file_can_read (const char *filename)
int file_is_dir (const char *filename)
char * get_filename_position (char *filename)
 Strips all directory stuff from filename and returns the position of where the actual filename starts.
char * expand_tilde (const char *filename)
 Tilde is only expanded for the current users homedir (~/).
char * get_unique_name (char *fileprefix)
 Generate a unique file name by trial and error based on the fileprefix by adding suffix counter (e.g. '.42').
char * get_tempdir_filename (const char *name)
 Checks various environment variables to get the name of the temp dir.
char * file_read_line (char *line, size_t *linesize, FILE *file, int *linenumber)
 Read a line from file into the dynamically allocated line, increasing line if necessary.
int safe_mkstemp (char *template_)
 Safe wrapper for mkstemp().
int mkalldirs (const char *path)
 Recursively create directories in path.
int compare_dir_entries (const void *v1, const void *v2)
The stat_* functions set the various attributes for directory entries.
static void stat_type (struct string *string, struct stat *stp)
static void stat_mode (struct string *string, struct stat *stp)
static void stat_links (struct string *string, struct stat *stp)
static void stat_user (struct string *string, struct stat *stp)
static void stat_group (struct string *string, struct stat *stp)
static void stat_size (struct string *string, struct stat *stp)
static void stat_date (struct string *string, struct stat *stp)

Function Documentation

◆ compare_dir_entries()

int compare_dir_entries ( const void * v1,
const void * v2 )

◆ expand_tilde()

char * expand_tilde ( const char * filename)

Tilde is only expanded for the current users homedir (~/).

The returned file name is allocated.

◆ file_can_read()

int file_can_read ( const char * filename)

◆ file_exists()

int file_exists ( const char * filename)

◆ file_is_dir()

int file_is_dir ( const char * filename)

◆ file_read_line()

char * file_read_line ( char * line,
size_t * linesize,
FILE * file,
int * linenumber )

Read a line from file into the dynamically allocated line, increasing line if necessary.

Ending whitespace is trimmed. If a line ends with "\" the next line is read too. If line is NULL the returned line is allocated and if file reading fails line is free()d.

◆ get_directory_entries()

struct directory_entry * get_directory_entries ( char * dirname,
int get_hidden )

First information such as permissions is gathered for each directory entry.

All entries are then sorted.

◆ get_filename_position()

char * get_filename_position ( char * filename)

Strips all directory stuff from filename and returns the position of where the actual filename starts.

◆ get_tempdir_filename()

char * get_tempdir_filename ( const char * name)

Checks various environment variables to get the name of the temp dir.

Returns a filename by concatenating "<tmpdir>/<name>".

◆ get_unique_name()

char * get_unique_name ( char * fileprefix)

Generate a unique file name by trial and error based on the fileprefix by adding suffix counter (e.g. '.42').

The returned file name is allocated if fileprefix is not unique.

◆ mkalldirs()

int mkalldirs ( const char * path)

Recursively create directories in path.

The last element in the path is taken to be a filename, and simply ignored

◆ safe_mkstemp()

int safe_mkstemp ( char * template_)

Safe wrapper for mkstemp().

It enforces permissions by calling umask(0177), call mkstemp(), then restore previous umask().

◆ stat_date()

void stat_date ( struct string * string,
struct stat * stp )
inlinestatic

◆ stat_group()

void stat_group ( struct string * string,
struct stat * stp )
inlinestatic

◆ stat_links()

void stat_links ( struct string * string,
struct stat * stp )
inlinestatic

◆ stat_mode()

void stat_mode ( struct string * string,
struct stat * stp )
inlinestatic

◆ stat_size()

void stat_size ( struct string * string,
struct stat * stp )
inlinestatic

◆ stat_type()

void stat_type ( struct string * string,
struct stat * stp )
inlinestatic

◆ stat_user()

void stat_user ( struct string * string,
struct stat * stp )
inlinestatic