plibsys 0.0.5
|
Filesystem interface. More...
Go to the source code of this file.
Data Structures | |
struct | PDirEntry_ |
Structure with directory entry information. More... | |
Typedefs | |
typedef struct PDir_ | PDir |
Directory opaque data structure. | |
typedef enum PDirEntryType_ | PDirEntryType |
Directory entry types. | |
typedef struct PDirEntry_ | PDirEntry |
Structure with directory entry information. | |
Enumerations | |
enum | PDirEntryType_ { P_DIR_ENTRY_TYPE_DIR = 1 , P_DIR_ENTRY_TYPE_FILE = 2 , P_DIR_ENTRY_TYPE_OTHER = 3 } |
Directory entry types. More... | |
Functions | |
P_LIB_API PDir * | p_dir_new (const pchar *path, PError **error) |
Creates a new PDir object. | |
P_LIB_API pboolean | p_dir_create (const pchar *path, pint mode, PError **error) |
Creates a new directory on a filesystem. | |
P_LIB_API pboolean | p_dir_remove (const pchar *path, PError **error) |
Removes an empty directory. | |
P_LIB_API pboolean | p_dir_is_exists (const pchar *path) |
Checks whether a directory exists or not. | |
P_LIB_API pchar * | p_dir_get_path (const PDir *dir) |
Gets the original directory path used to create a PDir object. | |
P_LIB_API PDirEntry * | p_dir_get_next_entry (PDir *dir, PError **error) |
Gets the next directory entry info. | |
P_LIB_API pboolean | p_dir_rewind (PDir *dir, PError **error) |
Resets a directory entry pointer. | |
P_LIB_API void | p_dir_entry_free (PDirEntry *entry) |
Frees PDirEntry object. | |
P_LIB_API void | p_dir_free (PDir *dir) |
Frees PDir object. | |
Filesystem interface.
A traditional filesystem can be presented as a combination of directories and files within a defined hierarchy. A directory contains the so called entries: files and other directories. PDir allows to iterate through these entries without reading their contents, thus building a filesystem hierarchy tree.
Think of this module as an interface to the well-known dirent
API.
First you need to open a directory for iterating through its content entries using p_dir_new(). After that every next entry inside the directory can be read with the p_dir_get_next_entry() call until it returns NULL (though it's better to check an error code to be sure no error occurred).
Also some directory manipulation routines are provided to create, remove and check existance.
Definition in file pdir.h.
enum PDirEntryType_ |
Creates a new directory on a filesystem.
path | Directory path. | |
mode | Directory permissions to use, ignored on Windows. | |
[out] | error | Error report object, NULL to ignore. |
Gets the next directory entry info.
dir | Directory to get the next entry from. | |
[out] | error | Error report object, NULL to ignore. |
Caller takes ownership of the returned object. Use p_dir_entry_free() to free memory of the directory entry after usage.
An error is set only if it is occurred. You should check the error object for P_ERROR_IO_NO_MORE code.
Checks whether a directory exists or not.
path | Directory path. |
Creates a new PDir object.
path | Directory path. |
[out] | error | Error report object, NULL to ignore. |
Removes an empty directory.
path | Directory path to remove. | |
[out] | error | Error report object, NULL to ignore. |
The directory path should be empty to be removed successfully.