|
muteki
|
Filesystem access API. More...
#include <muteki/common.h>Go to the source code of this file.
Data Structures | |
| struct | find_context_t |
| Structure for find context. More... | |
| struct | fs_stat_t |
| Filesystem usage statistics. More... | |
| struct | fn_parts_lfn_s |
| All-in-one struct that contain all parts used in _wfnsplit() and _wfnmerge() More... | |
| struct | fn_parts_dos_s |
| All-in-one struct that contain all parts used in _afnsplit() and _afnmerge() More... | |
Macros | |
| #define | SYS_PATH_MAX_CU 256u |
| Max code units (ASCII or UTF-16) a path can contain. | |
| #define | FIND_TS_YEAR(ts) ((ts >> 25) + 1980) |
| Read year from find timestamp. | |
| #define | FIND_TS_MONTH(ts) ((ts >> 21) & 0xf) |
| Read month from find timestamp. | |
| #define | FIND_TS_DAY(ts) ((ts >> 16) & 0x1f) |
| Read day from find timestamp. | |
| #define | FIND_TS_HOUR(ts) ((ts >> 11) & 0x1f) |
| Read hour from find timestamp. | |
| #define | FIND_TS_MINUTE(ts) ((ts >> 5) & 0x3f) |
| Read minute from find timestamp. | |
| #define | FIND_TS_SECOND(ts) ((ts & 0xf) * 4) |
| Read second from find timestamp. | |
| #define | FNSPLIT_LFN_PATHNAME_MAX 261u |
| #define | FNSPLIT_LFN_DRIVE_MAX 4u |
| #define | FNSPLIT_LFN_DIRNAME_MAX 257u |
| #define | FNSPLIT_LFN_BASENAME_MAX 257u |
| #define | FNSPLIT_LFN_SUFFIX_MAX 259u |
| #define | FNSPLIT_DOS_PATHNAME_MAX 81u |
| #define | FNSPLIT_DOS_DRIVE_MAX 4u |
| #define | FNSPLIT_DOS_DIRNAME_MAX 67u |
| #define | FNSPLIT_DOS_BASENAME_MAX 10u |
| #define | FNSPLIT_DOS_SUFFIX_MAX 9u |
Typedefs | |
| typedef struct fn_parts_lfn_s | fs_parts_lfn_t |
| All-in-one struct that contain all parts used in _wfnsplit() and _wfnmerge() | |
| typedef struct fn_parts_dos_s | fs_parts_dos_t |
| All-in-one struct that contain all parts used in _afnsplit() and _afnmerge() | |
Enumerations | |
| enum | fs_attribute_e { ATTR_READONLY = 0x1 , ATTR_HIDDEN = 0x2 , ATTR_SYSTEM = 0x4 , ATTR_DIR = 0x10 , ATTR_ARCHIVE = 0x20 , ATTR_DEVICE = 0x40 , ATTR_NONE = 0x80 } |
| File/directory attributes. More... | |
Functions | |
| bool | _aremove (const char *pathname) |
| Delete a file. | |
| bool | __wremove (const UTF16 *pathname) |
| Delete a file. | |
| short | _afindfirst (const char *fnmatch, find_context_t *ctx, int attrib_mask) |
| Begin a file/directory search. | |
| short | _afindnext (find_context_t *ctx) |
| Continue a previously started file/directory search. | |
| short | _wfindfirst (const UTF16 *fnmatch, find_context_t *ctx, int attrib_mask) |
| Begin a file/directory search (LFN support). | |
| short | _wfindnext (find_context_t *ctx) |
| Continue a previously started file/directory search. | |
| int | _findclose (find_context_t *ctx) |
| Terminate a file/directory search. | |
| short | _wfgetattr (UTF16 *path) |
| Get attributes of specific path. | |
| short | _wfsetattr (UTF16 *path, short attrs) |
| Set attributes of specific path. | |
| short | _afgetattr (char *path) |
| Get attributes of specific path. | |
| short | _afsetattr (char *path, short attrs) |
| Set attributes of specific path. | |
| int | _wmkdir (UTF16 *path) |
| Create a new directory. | |
| int | _amkdir (char *path) |
| Create a new directory. | |
| int | _wrmdir (UTF16 *path) |
| Remove a directory. | |
| int | _armdir (char *path) |
| Remove a directory. | |
| short | _agetcurdir (void *unk, char *buf) |
| Get system CWD value. | |
| short | _wgetcurdir (void *unk, UTF16 *buf) |
| Get system CWD value. | |
| short | _achdir (const char *path) |
| Change system working directory to a new path. | |
| short | _wchdir (const UTF16 *path) |
| Change system working directory to a new path. | |
| short | _arename (const char *old_path, const char *new_path) |
| Rename/move a file. | |
| short | _wrename (const UTF16 *old_path, const UTF16 *new_path) |
| Rename/move a file. | |
| int | FSGetDiskRoomState (int fsid, fs_stat_t *fs_stat) |
| Get filesystem usage stats. | |
| int | _afnsplit (const char *pathname, char *drive, char *dirname, char *basename, char *suffix) |
| Split a DOS 8.3 pathname into parts. | |
| int | _afnmerge (char *pathname, const char *drive, const char *dirname, const char *basename, const char *suffix) |
| Build an DOS 8.3 pathname from parts. | |
| int | _wfnsplit (const UTF16 *pathname, UTF16 *drive, UTF16 *dirname, UTF16 *basename, UTF16 *suffix) |
| Split an LFN pathname into parts. | |
| int | _wfnmerge (UTF16 *pathname, const UTF16 *drive, const UTF16 *dirname, const UTF16 *basename, const UTF16 *suffix) |
| Build an LFN pathname from parts. | |
Filesystem access API.
| #define FNSPLIT_DOS_BASENAME_MAX 10u |
Maximum number of code units a DOS 8.3 base name can have including the trailing NUL.
| #define FNSPLIT_DOS_DIRNAME_MAX 67u |
Maximum number of code units a DOS 8.3 directory name can have including the trailing NUL.
| #define FNSPLIT_DOS_DRIVE_MAX 4u |
Maximum number of code units a DOS 8.3 drive specifier can have including the trailing NUL.
| #define FNSPLIT_DOS_PATHNAME_MAX 81u |
Maximum number of code units an DOS 8.3 pathname can have including the trailing NUL.
| #define FNSPLIT_DOS_SUFFIX_MAX 9u |
Maximum number of code units a DOS 8.3 file suffix can have including the trailing NUL.
| #define FNSPLIT_LFN_BASENAME_MAX 257u |
Maximum number of code units an LFN base name can have including the trailing NUL.
| #define FNSPLIT_LFN_DIRNAME_MAX 257u |
Maximum number of code units an LFN directory name can have including the trailing NUL.
| #define FNSPLIT_LFN_DRIVE_MAX 4u |
Maximum number of code units an LFN drive specifier can have including the trailing NUL.
| #define FNSPLIT_LFN_PATHNAME_MAX 261u |
Maximum number of code units an LFN pathname can have including the trailing NUL.
| #define FNSPLIT_LFN_SUFFIX_MAX 259u |
Maximum number of code units an LFN file suffix can have including the trailing NUL.
| #define SYS_PATH_MAX_CU 256u |
Max code units (ASCII or UTF-16) a path can contain.
This includes the NUL terminator. Note that this can differ from libc definitions due to possible encoding differences (e.g. newlib-muteki uses UTF-8 as the "ANSI" encoding by default).
| enum fs_attribute_e |
|
extern |
Delete a file.
0x10274 | pathname | UTF-16 LFN path to the file being removed. |
| true | The operation was completed successfully. |
| false | The operation failed with error. |
|
extern |
Change system working directory to a new path.
0x100e2 | path | DOS 8.3 path. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Get attributes of specific path.
Similar to GetFileAttributeA() in Windows.
0x100db | path | DOS 8.3 path. |
|
extern |
Begin a file/directory search.
Matches the first file/directory based on fnmatch pattern fnmatch and attribute mask attrib_mask. Saves context at ctx, which can be used later with _afindnext() and _findclose().
0x100d8 | fnmatch | The pattern. |
| ctx | The context object. |
| attrib_mask | Attribute mask (use 0 to match everything regardless of attributes). |
| 0 | There is a match. |
| -1 | No more match was found. |
|
extern |
Continue a previously started file/directory search.
Matches the next file/directory.
0x100d9 | ctx | The context object. |
| 0 | There is a match. |
| -1 | No more match was found. |
|
extern |
Build an DOS 8.3 pathname from parts.
DOS 8.3 counterpart of _wfnmerge().
0x100c6 | [out] | pathname | Pointer to a buffer where the constructed pathname will be stored. This buffer must be at least as long as FNSPLIT_DOS_PATHNAME_MAX. |
| [in] | drive | Drive specifier (e.g., C or C:). If provided, it must be a valid drive name. |
| [in] | dirname | Directory path (e.g., \path\to\a\). If provided, it must end with a backslash. |
| [in] | basename | Base name without a suffix (e.g., file). |
| [in] | suffix | File suffix (e.g., .txt). |
|
extern |
Split a DOS 8.3 pathname into parts.
DOS 8.3 counterpart of _wfnsplit().
0x100c5 | [in] | pathname | Pathname to be split. |
| [out] | drive | Drive name, or NULL to omit this part. Must be at least as long as FNSPLIT_DOS_DRIVE_MAX. |
| [out] | dirname | Directory, or NULL to omit this part. Must be at least as long as FNSPLIT_DOS_DIRNAME_MAX. |
| [out] | basename | Basename without suffix, or NULL to omit this part. Must be at least as long as FNSPLIT_DOS_BASENAME_MAX. |
| [out] | suffix | Suffix, or NULL to omit this part. Must be at least as long as FNSPLIT_DOS_SUFFIX_MAX. |
|
extern |
Set attributes of specific path.
Similar to SetFileAttributeA() in Windows.
0x100dc | path | DOS 8.3 path. |
| attrs | The new attribute. |
|
extern |
Get system CWD value.
0x100e3 | unk | Some context object, format unknown. Use NULL to get the CWD of current applet. |
| buf | Buffer large enough to contain a DOS8.3 path. Must be at least SYS_PATH_MAX_CU bytes long. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Create a new directory.
0x100e0 | path | DOS 8.3 path to the new directory. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Delete a file.
0x100dd | pathname | DOS 8.3 path to the file being removed. |
| true | The operation was completed successfully. |
| false | The operation failed with error. |
|
extern |
Rename/move a file.
0x100de | old_path | Old DOS 8.3 path. |
| new_path | New DOS 8.3 path. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Remove a directory.
0x100e1Sets kerrno namespace to ERRNO_NS_KERNEL and error code to 0xffff when directory is not empty.
| path | DOS 8.3 path to the directory being removed. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Terminate a file/directory search.
0x100da | ctx | The context object. |
| 0 | The operation was completed successfully. |
|
extern |
Change system working directory to a new path.
0x10279 | path | UTF-16 LFN path. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Get attributes of specific path.
Similar to GetFileAttributeW() in Windows.
0x10272 | path | UTF-16 LFN path. |
|
extern |
Begin a file/directory search (LFN support).
Matches the first file/directory based on fnmatch pattern fnmatch and attribute mask attrib_mask. Saves context at ctx, which can be used later with _afindnext() and _findclose().
0x10270 | fnmatch | The pattern (encoded in UTF-16). |
| ctx | The context object. |
| attrib_mask | Attribute mask (use 0 to match everything regardless of attributes). |
| 0 | There is a match. |
| -1 | No more match was found. |
|
extern |
Continue a previously started file/directory search.
Matches the next file/directory.
Not sure if interchangeable with _afindnext() since it should have no dependency on different find context. Needs to be verified later.
0x10271 | ctx | The context object. |
| 0 | There is a match. |
| -1 | No more match was found. |
|
extern |
Build an LFN pathname from parts.
Borland libc style path parsing helper. It constructs a pathname by combining the components: drive, directory, basename, and suffix. It is designed to be the inverse of the _wfnsplit() syscall, allowing users to reconstruct a full pathname from its individual parts.
Each component is optional and can be provided as NULL if it is not needed in the final pathname. The syscall will concatenate the non-NULL components in the order of drive, directory, basename, and suffix, ensuring proper formatting such as adding backslashes where necessary.
Borland C++ has a documentation regarding to their implementation: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Fnmerge,_wfnmerge.
0x1026c | [out] | pathname | Pointer to a buffer where the constructed pathname will be stored. This buffer must be at least as long as FNSPLIT_LFN_PATHNAME_MAX. |
| [in] | drive | Drive specifier (e.g., C or C:). If provided, it must be a valid drive name. |
| [in] | dirname | Directory path (e.g., \path\to\a\). If provided, it must end with a backslash. |
| [in] | basename | Base name without a suffix (e.g., file). |
| [in] | suffix | File suffix (e.g., .txt). |
|
extern |
Split an LFN pathname into parts.
Borland libc style path parsing helper. It takes a pathname in the format of C:\path\to\a\file.txt and parse it into 4 parts:
C:)\path\to\a\)file).txt)Borland C++ has a documentation regarding to their implementation: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Fnsplit,_wfnsplit.
0x1026b | [in] | pathname | Pathname to be split. |
| [out] | drive | Drive name, or NULL to omit this part. Must be at least as long as FNSPLIT_LFN_DRIVE_MAX. |
| [out] | dirname | Directory, or NULL to omit this part. Must be at least as long as FNSPLIT_LFN_DIRNAME_MAX. |
| [out] | basename | Basename without suffix, or NULL to omit this part. Must be at least as long as FNSPLIT_LFN_BASENAME_MAX. |
| [out] | suffix | Suffix, or NULL to omit this part. Must be at least as long as FNSPLIT_LFN_SUFFIX_MAX. |
|
extern |
Set attributes of specific path.
Similar to SetFileAttributeW() in Windows.
0x10273 | path | UTF-16 LFN path. |
| attrs | The new attribute. |
|
extern |
Get system CWD value.
0x1027a | unk | Some context object, format unknown. Use NULL to get the CWD of current applet. |
| buf | Buffer large enough to contain a UTF-16 LFN path. Must be at least SYS_PATH_MAX_CU units long. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Create a new directory.
0x10277 | path | UTF-16 LFN path to the new directory. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
Rename/move a file.
0x10275 | old_path | Old UTF-16 LFN path. |
| new_path | New UTF-16 LFN path. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Remove a directory.
0x10278Sets kerrno namespace to ERRNO_NS_KERNEL and error code to 0xffff when directory is not empty.
| path | UTF-16 LFN path to the directory being removed. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Get filesystem usage stats.
0x100eb | fsid | Filesystem ID. |
| fs_stat | Target to store filesystem usage stats. |
| 0 | The operation was completed successfully. |