ELinks 0.16.1.1
|
File utilities. More...
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include "elinks.h"
#include "osdep/osdep.h"
#include "util/conv.h"
#include "util/error.h"
#include "util/file.h"
#include "util/memory.h"
Functions | |
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 *size, FILE *file, int *lineno) |
Read a line from file into the dynamically allocated line, increasing line if necessary. | |
int | safe_mkstemp (char *template_) |
Safe wrapper for mkstemp(). | |
int | compare_dir_entries (const void *v1, const void *v2) |
static int | file_visible (char *name, int get_hidden_files, int is_root_directory) |
This function decides whether a file should be shown in directory listing or not. | |
struct directory_entry * | get_directory_entries (char *dirname, int get_hidden) |
First information such as permissions is gathered for each directory entry. | |
int | mkalldirs (const char *path) |
Recursively create directories in path. |
File utilities.
int compare_dir_entries | ( | const void * | v1, |
const void * | v2 ) |
char * expand_tilde | ( | const char * | filename | ) |
Tilde is only expanded for the current users homedir (~/).
The returned file name is allocated.
int file_can_read | ( | const char * | filename | ) |
int file_exists | ( | const char * | filename | ) |
int file_is_dir | ( | const char * | filename | ) |
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.
|
inlinestatic |
This function decides whether a file should be shown in directory listing or not.
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.
char * get_filename_position | ( | char * | filename | ) |
Strips all directory stuff from filename and returns the position of where the actual filename starts.
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>".
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.
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