|
Muteki
EABI code execution on Besta® RTOS devices.
|
Filesystem path API. More...
#include "../common.h"Go to the source code of this file.
Data Structures | |
| struct | bxc_find_context_t |
| Structure for find context. More... | |
| struct | bxc_fs_stat_t |
| Filesystem usage statistics. More... | |
| struct | bxc_fs_parts_lfn_s |
| All-in-one struct that contain all parts used in _wfnsplit() and _wfnmerge(). More... | |
| struct | bxc_fs_parts_dos_s |
| All-in-one struct that contain all parts used in _afnsplit() and _afnmerge(). More... | |
Macros | |
| #define | BXC_FS_PATH_MAX_CU 256u |
| Max code units (ASCII or UTF-16) a path can contain. | |
| #define | BXC_FIND_TS_YEAR(ts) |
| Read year from find timestamp. | |
| #define | BXC_FIND_TS_MONTH(ts) |
| Read month from find timestamp. | |
| #define | BXC_FIND_TS_DAY(ts) |
| Read day from find timestamp. | |
| #define | BXC_FIND_TS_HOUR(ts) |
| Read hour from find timestamp. | |
| #define | BXC_FIND_TS_MINUTE(ts) |
| Read minute from find timestamp. | |
| #define | BXC_FIND_TS_SECOND(ts) |
| Read second from find timestamp. | |
| #define | BXC_FNSPLIT_LFN_PATHNAME_MAX 261u |
| #define | BXC_FNSPLIT_LFN_DRIVE_MAX 4u |
| #define | BXC_FNSPLIT_LFN_DIRNAME_MAX 257u |
| #define | BXC_FNSPLIT_LFN_BASENAME_MAX 257u |
| #define | BXC_FNSPLIT_LFN_SUFFIX_MAX 259u |
| #define | BXC_FNSPLIT_DOS_PATHNAME_MAX 81u |
| #define | BXC_FNSPLIT_DOS_DRIVE_MAX 4u |
| #define | BXC_FNSPLIT_DOS_DIRNAME_MAX 67u |
| #define | BXC_FNSPLIT_DOS_BASENAME_MAX 10u |
| #define | BXC_FNSPLIT_DOS_SUFFIX_MAX 9u |
Typedefs | |
| typedef struct bxc_fs_parts_lfn_s | bxc_fs_parts_lfn_t |
| All-in-one struct that contain all parts used in _wfnsplit() and _wfnmerge(). | |
| typedef struct bxc_fs_parts_dos_s | bxc_fs_parts_dos_t |
| All-in-one struct that contain all parts used in _afnsplit() and _afnmerge(). | |
Enumerations | |
| enum | fs_attribute_e { BXC_FS_ATTR_READONLY = 0x1 , BXC_FS_ATTR_HIDDEN = 0x2 , BXC_FS_ATTR_SYSTEM = 0x4 , BXC_FS_ATTR_DIR = 0x10 , BXC_FS_ATTR_ARCHIVE = 0x20 , BXC_FS_ATTR_DEVICE = 0x40 , BXC_FS_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, bxc_find_context_t *ctx, int attrib_mask) |
| Begin a file/directory search. | |
| short | _afindnext (bxc_find_context_t *ctx) |
| Continue a previously started file/directory search. | |
| short | _wfindfirst (const UTF16 *fnmatch, bxc_find_context_t *ctx, int attrib_mask) |
| Begin a file/directory search (LFN support). | |
| short | _wfindnext (bxc_find_context_t *ctx) |
| Continue a previously started file/directory search. | |
| int | _findclose (bxc_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, bxc_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 path API.
| #define BXC_FIND_TS_DAY | ( | ts | ) |
Read day from find timestamp.
| #define BXC_FIND_TS_HOUR | ( | ts | ) |
Read hour from find timestamp.
| #define BXC_FIND_TS_MINUTE | ( | ts | ) |
Read minute from find timestamp.
| #define BXC_FIND_TS_MONTH | ( | ts | ) |
Read month from find timestamp.
| #define BXC_FIND_TS_SECOND | ( | ts | ) |
Read second from find timestamp.
| #define BXC_FIND_TS_YEAR | ( | ts | ) |
Read year from find timestamp.
| #define BXC_FNSPLIT_DOS_BASENAME_MAX 10u |
Maximum number of code units a DOS 8.3 base name can have including the trailing NUL.
| #define BXC_FNSPLIT_DOS_DIRNAME_MAX 67u |
Maximum number of code units a DOS 8.3 directory name can have including the trailing NUL.
| #define BXC_FNSPLIT_DOS_DRIVE_MAX 4u |
Maximum number of code units a DOS 8.3 drive specifier can have including the trailing NUL.
| #define BXC_FNSPLIT_DOS_PATHNAME_MAX 81u |
Maximum number of code units an DOS 8.3 pathname can have including the trailing NUL.
| #define BXC_FNSPLIT_DOS_SUFFIX_MAX 9u |
Maximum number of code units a DOS 8.3 file suffix can have including the trailing NUL.
| #define BXC_FNSPLIT_LFN_BASENAME_MAX 257u |
Maximum number of code units an LFN base name can have including the trailing NUL.
| #define BXC_FNSPLIT_LFN_DIRNAME_MAX 257u |
Maximum number of code units an LFN directory name can have including the trailing NUL.
| #define BXC_FNSPLIT_LFN_DRIVE_MAX 4u |
Maximum number of code units an LFN drive specifier can have including the trailing NUL.
| #define BXC_FNSPLIT_LFN_PATHNAME_MAX 261u |
Maximum number of code units an LFN pathname can have including the trailing NUL.
| #define BXC_FNSPLIT_LFN_SUFFIX_MAX 259u |
Maximum number of code units an LFN file suffix can have including the trailing NUL.
| #define BXC_FS_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 |
File/directory attributes.
Just the attributes in FAT32.
|
extern |
Delete a file.
| 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.
| 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.
| 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().
| 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.
| 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().
| [out] | pathname | Pointer to a buffer where the constructed pathname will be stored. This buffer must be at least as long as BXC_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\\endiskip). 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().
| [in] | pathname | Pathname to be split. |
| [out] | drive | Drive name, or NULL to omit this part. Must be at least as long as BXC_FNSPLIT_DOS_DRIVE_MAX. |
| [out] | dirname | Directory, or NULL to omit this part. Must be at least as long as BXC_FNSPLIT_DOS_DIRNAME_MAX. |
| [out] | basename | Basename without suffix, or NULL to omit this part. Must be at least as long as BXC_FNSPLIT_DOS_BASENAME_MAX. |
| [out] | suffix | Suffix, or NULL to omit this part. Must be at least as long as BXC_FNSPLIT_DOS_SUFFIX_MAX. |
|
extern |
Set attributes of specific path.
Similar to SetFileAttributeA() in Windows.
| path | DOS 8.3 path. |
| attrs | The new attribute. |
|
extern |
Get system CWD value.
| 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 BXC_FS_PATH_MAX_CU bytes long. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Create a new directory.
| 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.
| 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.
| 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.
Sets kerrno namespace to BXC_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.
| ctx | The context object. |
| 0 | The operation was completed successfully. |
|
extern |
Change system working directory to a new path.
| 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.
| 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().
| 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.
| 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.
| [out] | pathname | Pointer to a buffer where the constructed pathname will be stored. This buffer must be at least as long as BXC_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\\endiskip). 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:
Borland C++ has a documentation regarding to their implementation: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Fnsplit,_wfnsplit.
| [in] | pathname | Pathname to be split. |
| [out] | drive | Drive name, or NULL to omit this part. Must be at least as long as BXC_FNSPLIT_LFN_DRIVE_MAX. |
| [out] | dirname | Directory, or NULL to omit this part. Must be at least as long as BXC_FNSPLIT_LFN_DIRNAME_MAX. |
| [out] | basename | Basename without suffix, or NULL to omit this part. Must be at least as long as BXC_FNSPLIT_LFN_BASENAME_MAX. |
| [out] | suffix | Suffix, or NULL to omit this part. Must be at least as long as BXC_FNSPLIT_LFN_SUFFIX_MAX. |
|
extern |
Set attributes of specific path.
Similar to SetFileAttributeW() in Windows.
| path | UTF-16 LFN path. |
| attrs | The new attribute. |
|
extern |
Get system CWD value.
| 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 BXC_FS_PATH_MAX_CU units long. |
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
|
extern |
Create a new directory.
| 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.
| 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.
Sets kerrno namespace to BXC_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.
| fsid | Filesystem ID. |
| fs_stat | Target to store filesystem usage stats. |
| 0 | The operation was completed successfully. |