coan 4.2.4
|
![]() |
Files | |
file | filesys.h |
Defines | |
#define | fs_absolute_path(pathtype) (((pathtype) & FS_ABS_PATH) == FS_ABS_PATH) |
#define | fs_unix_path(pathtype) (((pathtype) & FS_UNIX_PATH) == FS_UNIX_PATH) |
#define | fs_windows_path(pathtype) (((pathtype) & FS_WIN_PATH) == FS_WIN_PATH) |
#define | fs_dangling_path(pathtype) (((pathtype) & FS_DANGLING_PATH) == FS_DANGLING_PATH) |
#define | fs_root_path(pathtype) (((pathtype) & FS_ROOT_PATH) == FS_ROOT_PATH) |
#define | FS_IS_FILE(objtype) (((objtype) & FS_OBJ_FILE) != 0) |
#define | FS_IS_DIR(objtype) (((objtype) & FS_OBJ_DIR) != 0) |
#define | FS_IS_SLINK(objtype) (((objtype) & FS_OBJ_SLINK) != 0) |
Typedefs | |
typedef void * | fs_dir_t |
Enumerations | |
enum | fs_obj_type_t { FS_OBJ_NONE, FS_OBJ_SLINK = 1, FS_OBJ_FILE = 2, FS_OBJ_DIR = 4 } |
enum | fs_path_type_t { FS_ABS_PATH = 1, FS_UNIX_PATH = 2, FS_WIN_PATH = 6, FS_DANGLING_PATH = 8, FS_ROOT_PATH = 16 } |
Functions | |
fs_obj_type_t | fs_obj_type (char const *name) |
fs_obj_type_t | fs_file_or_dir (char const *name) |
fs_dir_t | fs_open_dir (char const *dirname, fs_dir_t const parent) |
void | fs_close_dir (fs_dir_t dir) |
char const * | fs_read_dir (fs_dir_t dir, char const **fullname) |
fs_dir_t | fs_get_parent (fs_dir_t dir) |
heap_str | fs_compose_filename (char const *path, char const *leafname) |
heap_str | fs_split_filename (char const *path, char **leafname) |
heap_str | fs_real_path (char const *relname, size_t *namelen) |
char const * | fs_cur_dir_entry (fs_dir_t dir, char const **entry) |
fs_path_type_t | fs_path_type (char const *filename) |
char * | fs_tempname (char *template) |
char const * | fs_path_comp (char const *first, char const *second, size_t *sharedlen) |
#define fs_absolute_path | ( | pathtype | ) | (((pathtype) & FS_ABS_PATH) == FS_ABS_PATH) |
#define fs_dangling_path | ( | pathtype | ) | (((pathtype) & FS_DANGLING_PATH) == FS_DANGLING_PATH) |
#define FS_IS_DIR | ( | objtype | ) | (((objtype) & FS_OBJ_DIR) != 0) |
The object type objtype indicates a directory
Definition at line 116 of file filesys.h.
Referenced by add_files().
#define FS_IS_FILE | ( | objtype | ) | (((objtype) & FS_OBJ_FILE) != 0) |
The object type objtype indicates a file
Definition at line 111 of file filesys.h.
Referenced by add_files(), and fs_split_filename().
#define FS_IS_SLINK | ( | objtype | ) | (((objtype) & FS_OBJ_SLINK) != 0) |
The object type objtype indicates a symbolic link
Definition at line 121 of file filesys.h.
Referenced by add_files(), file_tree_add(), file_tree_add_canon(), and new_dir_node().
#define fs_root_path | ( | pathtype | ) | (((pathtype) & FS_ROOT_PATH) == FS_ROOT_PATH) |
#define fs_unix_path | ( | pathtype | ) | (((pathtype) & FS_UNIX_PATH) == FS_UNIX_PATH) |
#define fs_windows_path | ( | pathtype | ) | (((pathtype) & FS_WIN_PATH) == FS_WIN_PATH) |
enum fs_obj_type_t |
enum fs_path_type_t |
Enumerated attributes of pathnames as returned by fs_path_type()
void fs_close_dir | ( | fs_dir_t | dir | ) |
Close an abstract directory handle, releasing its resources.
Definition at line 133 of file fs_nix.c.
References fs_dir_nix::dir, fs_dir_win::dirname, fs_dir_nix::dirname, and fs_dir_win::handle.
Referenced by file_tree_add_canon(), and new_dir_node().
heap_str fs_compose_filename | ( | char const * | path, |
char const * | leafname | ||
) |
Compose a filename from a path and a leafname. If either path or leafname is quoted or contains spaces then the resulting filename is quoted.
Definition at line 50 of file filesys.c.
References PATH_DELIM, and zallocate().
Referenced by file_tree_name().
char const* fs_cur_dir_entry | ( | fs_dir_t | dir, |
char const ** | entry | ||
) |
Return the absolute pathname of the current entry from a directory handle.
dir | Directory handle |
entry | NULL, or an address at which the function shall store a pointer to the terminal portion of the current full pathname that follows the full pathname of dir. |
The current entry in dir is the entry read by the last call to fs_read_dir(dir), if any. If fs_read_dir(dir) has not yet been called, or if the last call returned NULL, then the returned pointer addresses the absolute name of dir and, if leafname is not NULL, then *leafname[0] will be 0.
Otherwise, if leafname is not NULL then *leafname will point to the last component of the current absolute pathname commencing with '/' (unix) or '\' (windows)
Definition at line 181 of file fs_nix.c.
References fs_dir_win::dirname, fs_dir_nix::dirname, fs_dir_win::dirname_end, and fs_dir_nix::dirname_end.
Referenced by file_tree_add_symlink(), and new_dir_node().
fs_obj_type_t fs_file_or_dir | ( | char const * | name | ) |
Return the type of the putative file or directory designated by a filename. Bail if neither file nor directory.
Definition at line 64 of file filesys.c.
References bail(), FS_OBJ_NONE, fs_obj_type(), and GRIPE_NO_FILE.
Referenced by file_tree_add(), and fs_split_filename().
Return the handle of the open parent directory of a directory, if any, else NULL.
Definition at line 192 of file fs_nix.c.
References fs_dir_win::parent, and fs_dir_nix::parent.
Referenced by file_tree_add_symlink().
fs_obj_type_t fs_obj_type | ( | char const * | name | ) |
Return the type of the object putatively designated by a filename
Definition at line 91 of file fs_nix.c.
References FS_OBJ_DIR, FS_OBJ_FILE, FS_OBJ_NONE, FS_OBJ_SLINK, and fs_dir_win::obj_info.
Referenced by add_files(), file_tree_add_canon(), fs_file_or_dir(), fs_tempname(), and new_dir_node().
Open an abstract directory handle through which the contents of a directory can be traversed.
dirname | The name of the directory to be opened. |
parent | The handle of the open directory of dirname is a subdirectory, or NULL if none. |
errno
. Definition at line 113 of file fs_nix.c.
References fs_dir_nix::dir, fs_dir_win::dirname, fs_dir_nix::dirname, fs_dir_win::dirname_end, fs_dir_nix::dirname_end, fs_real_path(), fs_dir_win::handle, HANDLE, fs_dir_win::obj_info, fs_dir_win::parent, fs_dir_nix::parent, PATH_DELIM, reallocate(), and zallocate().
Referenced by file_tree_add_canon(), and new_dir_node().
char const* fs_path_comp | ( | char const * | first, |
char const * | second, | ||
size_t * | sharedlen | ||
) |
Compare two pathnames.
first | The first pathname. |
second | The second pathname. |
sharedlen | Address of an integer at which the function shall store the length of any common initial component of first and second unless they are identical pathnames, in which case 0 shall be stored at sharedlen. |
If the returned value cp is non-NULL then it is equal to either first or to second. Then:
If the returned value is NULL then first and second are wholly disjoint pathnames.
Definition at line 129 of file filesys.c.
References PATH_DELIM.
Referenced by file_tree_add_symlink().
fs_path_type_t fs_path_type | ( | char const * | filename | ) |
Get the type of a pathname
Definition at line 95 of file filesys.c.
References FS_ABS_PATH, FS_DANGLING_PATH, FS_ROOT_PATH, FS_UNIX_PATH, and FS_WIN_PATH.
Referenced by seek().
char const* fs_read_dir | ( | fs_dir_t | dir, |
char const ** | fullname | ||
) |
Get the name of the next entry in a directory.
dir | The open directory handle to read. |
fullname | NULL, or a pointer at which the function will store the address of the absolute name of the entry returned. This pointer is only valid until the next call or until fs_close_dir(dir) |
The function ignores the entries '.' and '..'.
Definition at line 145 of file fs_nix.c.
References bail(), fs_dir_nix::dir, fs_dir_win::dirname, fs_dir_nix::dirname, fs_dir_win::dirname_end, fs_dir_nix::dirname_end, fs_dir_nix::entry, fs_read_dir(), GRIPE_CANT_READ_DIR, fs_dir_win::handle, fs_dir_win::obj_info, PATH_DELIM, and reallocate().
Referenced by file_tree_add_canon(), fs_read_dir(), and new_dir_node().
heap_str fs_real_path | ( | char const * | relname, |
size_t * | namelen | ||
) |
Return the absolute real pathname of a file or directory name (which may be the name of a symbolic link).
relname | Possibly relative file or directory name. |
namelen | If non-NULL then the length of the absolute real name of relname is stored here at return. |
relname
in a string allocated on the heap. It is the caller's responsiblity to free this string. NULL is returned if an error occurs. Definition at line 74 of file fs_nix.c.
References zallocate().
Referenced by file_tree_add(), file_tree_add_symlink(), and fs_open_dir().
heap_str fs_split_filename | ( | char const * | path, |
char ** | leafname | ||
) |
Split at filename into its parent directory component and its terminal component.
path | Path to be split |
leafname | NULL, or an address at which the function will store the address of the terminal component of path. |
If path has only one component then, if that component is a directory, it is returned and NULL will be stored at leafname; if the one component is a file then NULL is returned
Definition at line 160 of file filesys.c.
References fs_file_or_dir(), FS_IS_FILE, PATH_DELIM, and zallocate().
Referenced by file_tree_add_canon().
char* fs_tempname | ( | char * | template | ) |
Create a tempory filename from a template
template | A pathname pattern from which to compose the temporary filename. |
The writable string template
must terminate with XXXXXX
This suffix will be replaced, if possible, with a string of characters to compose a filename different from that of any existing file.
Definition at line 74 of file filesys.c.
References FS_OBJ_NONE, and fs_obj_type().
Referenced by make_tempfile().