N64FlashcartMenu
Loading...
Searching...
No Matches
fs.c File Reference

Implementation of file system utility functions. More...

Functions

char * strip_fs_prefix (char *path)
 Strip the file system prefix from a path.
 
char * file_basename (char *path)
 Get the basename of a path.
 
bool file_exists (char *path)
 Check if a file exists at the given path.
 
int64_t file_get_size (char *path)
 Get the size of a file at the given path.
 
bool file_allocate (char *path, size_t size)
 Allocate a file of the specified size at the given path.
 
bool file_fill (char *path, uint8_t value)
 Fill a file with the specified value.
 
bool file_has_extensions (char *path, const char *extensions[])
 Check if a file has one of the specified extensions.
 
bool directory_exists (char *path)
 Check if a directory exists at the given path.
 
bool directory_create (char *path)
 Create a directory at the given path.
 

Detailed Description

Implementation of file system utility functions.

Function Documentation

◆ strip_fs_prefix()

char * strip_fs_prefix ( char * path)

Strip the file system prefix from a path.

Removes the file system prefix (such as ":/") from the provided path string.

Parameters
pathThe path from which to strip the prefix.
Returns
A pointer to the path without the prefix.

◆ file_basename()

char * file_basename ( char * path)

Get the basename of a path.

Returns a pointer to the basename (the final component) of the provided path.

Parameters
pathThe path from which to get the basename.
Returns
A pointer to the basename of the path.

◆ file_exists()

bool file_exists ( char * path)

Check if a file exists at the given path.

Checks if a file exists at the specified path.

Parameters
pathThe path to the file.
Returns
true if the file exists, false otherwise.

◆ file_get_size()

int64_t file_get_size ( char * path)

Get the size of a file at the given path.

Returns the size of the file at the specified path in bytes.

Parameters
pathThe path to the file.
Returns
The size of the file in bytes, or -1 if the file does not exist or an error occurs.

◆ file_allocate()

bool file_allocate ( char * path,
size_t size )

Allocate a file of the specified size at the given path.

Creates a file of the specified size at the provided path. The file is filled with zeros.

Parameters
pathThe path to the file.
sizeThe size of the file to create in bytes.
Returns
true if the file was successfully created, false otherwise.

◆ file_fill()

bool file_fill ( char * path,
uint8_t value )

Fill a file with the specified value.

Fills the file at the given path with the specified byte value.

Parameters
pathThe path to the file.
valueThe value to fill the file with (byte).
Returns
true if the file was successfully filled, false otherwise.

◆ file_has_extensions()

bool file_has_extensions ( char * path,
const char * extensions[] )

Check if a file has one of the specified extensions.

Checks if the file at the given path has one of the specified extensions.

Parameters
pathThe path to the file.
extensionsAn array of extensions to check (NULL-terminated).
Returns
true if the file has one of the specified extensions, false otherwise.

◆ directory_exists()

bool directory_exists ( char * path)

Check if a directory exists at the given path.

Checks if a directory exists at the specified path.

Parameters
pathThe path to the directory.
Returns
true if the directory exists, false otherwise.

◆ directory_create()

bool directory_create ( char * path)

Create a directory at the given path.

Creates a directory at the specified path, including any necessary parent directories.

Parameters
pathThe path to the directory.
Returns
false if the directory was successfully created, true if there was an error.