libnds
|
Simple replacement of libfat. More...
Functions | |
int | FAT_getAttr (const char *file) |
Get FAT attributes of a file. | |
int | FAT_setAttr (const char *file, uint8_t attr) |
Set FAT attributes of a file. | |
WARN_UNUSED_RESULT char * | fatGetDefaultCwd (void) |
This function returns the default current working directory. | |
const char * | fatGetDefaultDrive (void) |
This function returns the default drive ("sd:/" or "fat:/"). | |
WARN_UNUSED_RESULT bool | fatInit (int32_t cache_size_pages, bool set_as_default_device) |
This function initializes the FAT filesystem with a default cache size. | |
WARN_UNUSED_RESULT bool | fatInitDefault (void) |
This function calls fatInit() with the default cache size (5 pages = 20 KB). | |
int | fatInitLookupCache (int fd, uint32_t max_buffer_size) |
This function initializes a lookup cache on a given FAT file. For NitroFS, use. | |
Simple replacement of libfat.
int FAT_getAttr | ( | const char * | file | ) |
Get FAT attributes of a file.
This function works when used on NitroFS.
On error, this function sets errno to an error code.
file | Path to the file. |
int FAT_setAttr | ( | const char * | file, |
uint8_t | attr | ||
) |
Set FAT attributes of a file.
This function fails when used on NitroFS (it's read-only).
On error, this function sets errno to an error code.
file | Path to the file. |
attr | A combination of ATTR_* flags with the new attributes of the file. |
WARN_UNUSED_RESULT char * fatGetDefaultCwd | ( | void | ) |
This function returns the default current working directory.
It is extracted from argv[0] if it has been provided by the loader. If the format of the path provided by the loader is incorrect, or if no argv[0] was provided, it will default to the root of the filesystem.
The string is allocated with strdup() internally, so the caller of fatGetDefaultCwd() must use free() to free it.
For example, this function may return "sd:/folder/" or "fat:/".
const char * fatGetDefaultDrive | ( | void | ) |
This function returns the default drive ("sd:/" or "fat:/").
It is extracted from argv[0] if it has been provided by the loader.
If the format of the path provided by the loader is incorrect, or if no argv[0] was provided, it will default to the root of the filesystem. In the case of DSi, the default drive is the SD card. In the case of DS, the default drive is DLDI.
The returned string must not be passed to free().
WARN_UNUSED_RESULT bool fatInit | ( | int32_t | cache_size_pages, |
bool | set_as_default_device | ||
) |
This function initializes the FAT filesystem with a default cache size.
It works differently in a regular DS than in a DSi:
The initial working directory is "fat:/" on the DS (DLDI), and "sd:/" on DSi. On the DSi it is possible to switch between both filesystems with chdir()
.
This function can be called multiple times, only the first one has any effect. Any call after the first one returns the value returned the first time.
cache_size_pages | The desired size in pages. One page is made of 8 sectors (512 bytes each, 4KB in total). Values < 0 leave the cache size decision to the FAT filesystem implementation. |
set_as_default_device | Ignored, kept for compatibility with libfat. |
WARN_UNUSED_RESULT bool fatInitDefault | ( | void | ) |
This function calls fatInit() with the default cache size (5 pages = 20 KB).
int fatInitLookupCache | ( | int | fd, |
uint32_t | max_buffer_size | ||
) |
This function initializes a lookup cache on a given FAT file. For NitroFS, use.
This lookup cache allows avoiding expensive SD card lookups for large and/or backwards lookups, at the expensive of RAM usage.
Note that, if the file is opened for writing, using this function will prevent the file's size from being expanded.
fd | The file descriptor to initialize. Use fileno(file) for FILE * inputs. |
max_buffer_size | The maximum buffer size, in bytes. |