Mstdlib-1.24.0
|
Functions | |
size_t | M_fs_path_get_path_max (M_fs_system_t sys_type) |
M_bool | M_fs_path_isabs (const char *p, M_fs_system_t sys_type) |
M_bool | M_fs_path_isunc (const char *p) |
M_bool | M_fs_path_ishidden (const char *path, const M_fs_info_t *info) |
M_list_str_t * | M_fs_path_componentize_path (const char *path, M_fs_system_t sys_type) |
char * | M_fs_path_join (const char *p1, const char *p2, M_fs_system_t sys_type) |
char * | M_fs_path_join_parts (const M_list_str_t *path, M_fs_system_t sys_type) |
char * | M_fs_path_join_vparts (M_fs_system_t sys_type, size_t num,...) |
char * | M_fs_path_join_resolved (const char *path, const char *part, const char *resolved_name, M_fs_system_t sys_type) |
char * | M_fs_path_dirname (const char *path, M_fs_system_t sys_type) |
char * | M_fs_path_basename (const char *path, M_fs_system_t sys_type) |
char * | M_fs_path_user_confdir (M_fs_system_t sys_type) |
char * | M_fs_path_tmpdir (M_fs_system_t sys_type) |
M_fs_error_t | M_fs_path_get_cwd (char **cwd) |
M_fs_error_t | M_fs_path_set_cwd (const char *path) |
M_fs_error_t | M_fs_path_readlink (char **out, const char *path) |
M_fs_error_t | M_fs_path_norm (char **out, const char *path, M_uint32 flags, M_fs_system_t sys_type) |
size_t M_fs_path_get_path_max | ( | M_fs_system_t | sys_type | ) |
Determine the max path length for the system.
[in] | sys_type | The system type used to determine the maximum path length. |
M_bool M_fs_path_isabs | ( | const char * | p, |
M_fs_system_t | sys_type | ||
) |
Check if a path is an absolute path.
A path is absolute if it's Unix and starts with /. Or Windows and starts with \\ (UNC) or a drive letter.
[in] | p | The path. |
[in] | sys_type | The system type. |
M_bool M_fs_path_isunc | ( | const char * | p | ) |
Check if a path is a UNC path.
A path is UNC if it's Windows and starts with "\\\\".
[in] | p | The path. |
M_bool M_fs_path_ishidden | ( | const char * | path, |
const M_fs_info_t * | info | ||
) |
Check if the path is considered hidden by the OS.
Either the path or info parameters can be NULL. Both cannot be NULL.
[in] | path | The path. |
[in] | info | The info. |
M_list_str_t * M_fs_path_componentize_path | ( | const char * | path, |
M_fs_system_t | sys_type | ||
) |
Take a path and split it into components.
This will remove empty parts. An absolute path (Unix) starting with / will have the / replaced with an empty to start the list. The same is true for UNC paths. An empty at the start of the path list should be treated as an absolute path.
[in] | path | The path. |
[in] | sys_type | The system type. |
char * M_fs_path_join | ( | const char * | p1, |
const char * | p2, | ||
M_fs_system_t | sys_type | ||
) |
Join two parts into one path.
If either part is empty the separator won't be added. Unlike M_fs_path_join_parts this does not have special handling (using an empty string) for absolute paths. This is a convenience function to write the appropriate system separator between two paths.
[in] | p1 | First part. |
[in] | p2 | Second part. |
[in] | sys_type | The system type. |
char * M_fs_path_join_parts | ( | const M_list_str_t * | path, |
M_fs_system_t | sys_type | ||
) |
Take a list of path components and join them into a string separated by the system path separator.
Empty parts (except the first on Unix and UNC) will be ignored. An empty part at the start is used on Unix and UNC to denote an absolute path.
[in] | path | The path. |
[in] | sys_type | The system type. |
char * M_fs_path_join_vparts | ( | M_fs_system_t | sys_type, |
size_t | num, | ||
... | |||
) |
Take a list of path components and join them into a string separated by the system path separator.
Empty parts (except the first on Unix and UNC) will be ignored. An empty part at the start is used on Unix and UNC to denote an absolute path.
[in] | sys_type | The system type. |
[in] | num | The number of parts. |
[in] | ... | char * parts to be joined. |
char * M_fs_path_join_resolved | ( | const char * | path, |
const char * | part, | ||
const char * | resolved_name, | ||
M_fs_system_t | sys_type | ||
) |
Join a base path, the name and the resolved name into the full resolved path.
This is a helper for dealing with M_fs_dir_walk in order to determine the resolved path when the entry returned by the callback is a symlink.
We have three parts: path, entry_name, resolved_name. The entry_name needs to have the last part removed because it is a symlink. Then we need to put path and resolved_name on either size to get the real name.
For example: path = /usr/share/zoneinfo/America part = Indiana/Indianapolis resolved_name = ../../posix/America/Indiana/Indianapolis
We need: /usr/share/zoneinfo/America/Indiana/../../posix/America/Indiana/Indianapolis
[in] | path | The base path. |
[in] | part | The path component under the base. |
[in] | resolved_name | The resolved path for a symlink that needs to be combined with the base and part. |
[in] | sys_type | The system type. |
char * M_fs_path_dirname | ( | const char * | path, |
M_fs_system_t | sys_type | ||
) |
Strip last component from a filename.
Remove last full non-slash component. Output will not include trailing slashes. E.g: /usr/bin/echo.exe -> /usr/bin
A path without a dir component will output NULL as there is no directory and cannot be assumed to be a relative path.
[in] | path | The path. |
[in] | sys_type | The system path logic and separator to use. |
char * M_fs_path_basename | ( | const char * | path, |
M_fs_system_t | sys_type | ||
) |
Strip all but the last component from a filename.
Remove all but the last full non-slash component. Output will not include trailing slashes.
E.g: /usr/bin/ -> bin
E.g: bin -> bin
[in] | path | The path. |
[in] | sys_type | The system path logic and separator to use. |
char * M_fs_path_user_confdir | ( | M_fs_system_t | sys_type | ) |
The user's configuration directory.
This is a user level not system level directory. This is the OS standard directory for application configuration files.
[in] | sys_type | The system path logic and separator to use. |
char * M_fs_path_tmpdir | ( | M_fs_system_t | sys_type | ) |
Temporary directory set by the system that the application can use for temporary storage.
Other processes on the system can share this directory. It's recommend to create an applications specific subdirectory to use for temporary files. Again, this is NOT intended to be used for secure files or when secure files are necessary.
This should only be used for temporary storage of files being manipulated. For example, unpacking a compressed archive then moving the files to the destination. Or saving to a temporary file then using M_fs_move to ensure an atomic write.
[in] | sys_type | The system path logic and separator to use. |
M_fs_error_t M_fs_path_get_cwd | ( | char ** | cwd | ) |
Get the current working directory for the calling process.
[in] | cwd | An allocated string with the cwd. |
M_fs_error_t M_fs_path_set_cwd | ( | const char * | path | ) |
Set the current working directory for the calling process.
[in] | path | The path to set as the cwd. |
M_fs_error_t M_fs_path_readlink | ( | char ** | out, |
const char * | path | ||
) |
Resolve a symlink.
Reads the value pointed to by a symlink.
[out] | out | An allocated string with the normalized path. |
[in] | path | The path to resolve. |
M_fs_error_t M_fs_path_norm | ( | char ** | out, |
const char * | path, | ||
M_uint32 | flags, | ||
M_fs_system_t | sys_type | ||
) |
Normalize a path.
This typically does not need to be called because all functions that take a path (file) will call this internally using the appropriate parameters. This is provided as a convenience for displaying paths to a user.
Supported features on all OS's;
Supported feature Unix only:
[out] | out | An allocated string with the normalized path. |
[in] | path | The path to normalize. |
[in] | flags | M_fs_path_norm_t flags to control the normalization behavior. |
[in] | sys_type | The system path format to the path is in. This denotes the path type and how it should be normalized. For example, a Windows path with "C:\..." passed with the UNIX type will do strange things because it is not a Unix formatted path. The purpose of this argument is to specify the path type if known. Allows a Windows path on a Unix system to be parsed properly even though it's not the standard path type for the system. Note that if the path is not the same as the system standard type the M_FS_PATH_NORM_ABSOLUTE my give unexpected results for non-absolute paths. For example this relative path specified as a Windows path run on a Unix system: ".\\abc.\\\\\\..\\xyz\\\\.\\123\\.\\xyr\\." may result in something like May give a result like: "home\jschember\svn\mstdlib-trunk\build\xyz\123\xyr" Notice there is no '\' or drive letter because they are not technically valid. However, the path was properly converted to an absolute path. |