Mstdlib-1.24.0
Directory

Functions

void M_fs_dir_entry_destroy (M_fs_dir_entry_t *entry) M_FREE(1)
 
M_fs_type_t M_fs_dir_entry_get_type (const M_fs_dir_entry_t *entry)
 
M_bool M_fs_dir_entry_get_ishidden (const M_fs_dir_entry_t *entry)
 
const char * M_fs_dir_entry_get_name (const M_fs_dir_entry_t *entry)
 
const char * M_fs_dir_entry_get_resolved_name (const M_fs_dir_entry_t *entry)
 
const M_fs_info_tM_fs_dir_entry_get_info (const M_fs_dir_entry_t *entry)
 
void M_fs_dir_entries_destroy (M_fs_dir_entries_t *d) M_FREE(1)
 
void M_fs_dir_entries_sort (M_fs_dir_entries_t *d, M_fs_dir_sort_t primary_sort, M_bool primary_asc, M_fs_dir_sort_t secondary_sort, M_bool secondary_asc)
 
size_t M_fs_dir_entries_len (const M_fs_dir_entries_t *d)
 
const M_fs_dir_entry_tM_fs_dir_entries_at (const M_fs_dir_entries_t *d, size_t idx)
 
M_fs_dir_entry_tM_fs_dir_entries_take_at (M_fs_dir_entries_t *d, size_t idx)
 
M_bool M_fs_dir_entries_remove_at (M_fs_dir_entries_t *d, size_t idx)
 
M_bool M_fs_dir_entries_remove_range (M_fs_dir_entries_t *d, size_t start, size_t end)
 
void M_fs_dir_entries_merge (M_fs_dir_entries_t **dest, M_fs_dir_entries_t *src) M_FREE(2)
 
void M_fs_dir_walk (const char *path, const char *pat, M_uint32 filter, M_fs_dir_walk_cb_t cb, void *thunk)
 
M_fs_dir_entries_tM_fs_dir_walk_entries (const char *path, const char *pat, M_uint32 filter)
 
M_list_str_tM_fs_dir_walk_strs (const char *path, const char *pat, M_uint32 filter)
 
M_fs_error_t M_fs_dir_mkdir (const char *path, M_bool create_parents, M_fs_perms_t *perms)
 

Detailed Description

Function Documentation

◆ M_fs_dir_entry_destroy()

void M_fs_dir_entry_destroy ( M_fs_dir_entry_t entry)

Destroy a directory entry.

Parameters
[in]entryThe entry to destroy.

◆ M_fs_dir_entry_get_type()

M_fs_type_t M_fs_dir_entry_get_type ( const M_fs_dir_entry_t entry)

Get the type of the entry.

Parameters
[in]entryThe entry.
Returns
The type.

◆ M_fs_dir_entry_get_ishidden()

M_bool M_fs_dir_entry_get_ishidden ( const M_fs_dir_entry_t entry)

Get whether this entry is considered hidden by the OS.

Parameters
[in]entryThe entry.
Returns
Whether this entry is considered hidden.

◆ M_fs_dir_entry_get_name()

const char * M_fs_dir_entry_get_name ( const M_fs_dir_entry_t entry)

Get the filename of the entry.

The path/filename is relative to the directory that was walked.

Parameters
[in]entryThe entry.
Returns
The name.

◆ M_fs_dir_entry_get_resolved_name()

const char * M_fs_dir_entry_get_resolved_name ( const M_fs_dir_entry_t entry)

Get the resolved filename.

This only applies if the entry is a symlink. The resolved name is the path that the symlink points to. This is relative to the filename.

Parameters
[in]entryThe entry.
Returns
The resolved name.

◆ M_fs_dir_entry_get_info()

const M_fs_info_t * M_fs_dir_entry_get_info ( const M_fs_dir_entry_t entry)

Get the file information about the entry.

This may be NULL if reading file info was not requested during walk.

Parameters
[in]entryThe entry.
Returns
The file info.

◆ M_fs_dir_entries_destroy()

void M_fs_dir_entries_destroy ( M_fs_dir_entries_t d)

Destroy a list of directory entries.

Parameters
[in]dThe entry list to destroy.

◆ M_fs_dir_entries_sort()

void M_fs_dir_entries_sort ( M_fs_dir_entries_t d,
M_fs_dir_sort_t  primary_sort,
M_bool  primary_asc,
M_fs_dir_sort_t  secondary_sort,
M_bool  secondary_asc 
)

Sort a list of directory entries.

This does an in place sort and does not keep list sorted for subsequent insertions.

Parameters
[in]dThe entry list.
[in]primary_sortPrimary sort method.
[in]primary_ascShould the primary sorting be ascending.
[in]secondary_sortThe secondary sort method that should be used when entries are considered equal according to the primary_sort method.
[in]secondary_ascShould the secondary sorting be ascending.

◆ M_fs_dir_entries_len()

size_t M_fs_dir_entries_len ( const M_fs_dir_entries_t d)

Get the number of entries in the list.

Parameters
[in]dThe entry list.
Returns
The length of the list.

◆ M_fs_dir_entries_at()

const M_fs_dir_entry_t * M_fs_dir_entries_at ( const M_fs_dir_entries_t d,
size_t  idx 
)

Get the entry at at the specified index.

The entry remains part of the list.

Parameters
[in]dThe entry list.
[in]idxThe index.
Returns
The entry.

◆ M_fs_dir_entries_take_at()

M_fs_dir_entry_t * M_fs_dir_entries_take_at ( M_fs_dir_entries_t d,
size_t  idx 
)

Take the entry from the list.

The entry will be removed from the list. It is up to the caller to free the entry.

Parameters
[in]dThe entry list.
[in]idxThe index.
Returns
The entry.
See also
M_fs_dir_entry_destroy

◆ M_fs_dir_entries_remove_at()

M_bool M_fs_dir_entries_remove_at ( M_fs_dir_entries_t d,
size_t  idx 
)

Remove and destroy the entry at the given index.

Parameters
[in]dThe entry list.
[in]idxThe index.
Returns
M_TRUE if the entry was destroyed. Otherwise M_FALSE.

◆ M_fs_dir_entries_remove_range()

M_bool M_fs_dir_entries_remove_range ( M_fs_dir_entries_t d,
size_t  start,
size_t  end 
)

Remove and destroy all entries in a given range.

Parameters
[in]dThe entry list.
[in]startThe starting index. Inclusive.
[in]endThe ending index. Inclusive.
Returns
M_TRUE if the entry was destroyed. Otherwise M_FALSE.

◆ M_fs_dir_entries_merge()

void M_fs_dir_entries_merge ( M_fs_dir_entries_t **  dest,
M_fs_dir_entries_t src 
)

Merge two directory entry lists together.

The second (src) list will be destroyed automatically upon completion of this function. Any value pointers for the list will be directly copied over to the destination list, they will not be duplicated.

Parameters
[in,out]destPointer by reference to the list receiving the values. if this is NULL, the pointer will simply be switched out for src.
[in,out]srcPointer to the list giving up its values.

◆ M_fs_dir_walk()

void M_fs_dir_walk ( const char *  path,
const char *  pat,
M_uint32  filter,
M_fs_dir_walk_cb_t  cb,
void *  thunk 
)

List the contents of a directory by walking the tree.

The tree will be walked depth first. When searching for both directory and file contents, the directory entry will come after entries for the directories contents. Support for modifying while walking is OS and filesystem dependent. Thus, behavior while modifying the contents of a directory during a walk is undefined.

Parameters
[in]pathThe path to walk.
[in]patGlob style pattern to filter entries in the tree. Only entries matching the pattern will be included in the output. NULL, "", and "*" will match all entries.
[in]filterM_fs_dir_walk_filter_t flags controlling the behavior of the walk.
[in]cbCallback for entries.
[in]thunkAdditional data passed to the callback.

◆ M_fs_dir_walk_entries()

M_fs_dir_entries_t * M_fs_dir_walk_entries ( const char *  path,
const char *  pat,
M_uint32  filter 
)

List the contents of a directory by walking the tree.

Parameters
[in]pathThe path to walk.
[in]patGlob style pattern to filter entries in the tree. Only entries matching the pattern will be included in the output. NULL, "", and "*" will match all entries.
[in]filterM_fs_dir_walk_filter_t flags controlling the behavior of the walk.
Returns
A list of entries in the dir. The entries are relative to the specified path.

◆ M_fs_dir_walk_strs()

M_list_str_t * M_fs_dir_walk_strs ( const char *  path,
const char *  pat,
M_uint32  filter 
)

List the contents of a directory as a list of string paths by walking the tree.

Parameters
[in]pathThe path to walk.
[in]patGlob style pattern to filter entries in the tree. Only entries matching the pattern will be included in the output. NULL, "", and "*" will match all entries.
[in]filterM_fs_dir_walk_filter_t flags controlling the behavior of the walk.
Returns
A list of string paths that are the contents of the dir. The entries are relative to the specified path. Directory entries in the output list will end with the OS path separator.

◆ M_fs_dir_mkdir()

M_fs_error_t M_fs_dir_mkdir ( const char *  path,
M_bool  create_parents,
M_fs_perms_t perms 
)

Create a directory.

Parameters
[in]pathThe directory to create.
[in]create_parentsWhen M_TRUE create the any parents of the last directory if they do not exist instead of erroring.
[in]permsAdditional perms to apply to the created directory. If perms is NULL a default perms of rw-rw-r– & ~umask is used.
Returns
Result.