My Project
Loading...
Searching...
No Matches
vfs.h File Reference
#include "../fat32/fat32.h"

Go to the source code of this file.

Data Structures

struct  FS_DRIVER

Typedefs

typedef enum _FS_WRITE_MODES FS_WRITE_MODES
typedef struct FS_DRIVER FS_DRIVER

Enumerations

enum  _FS_WRITE_MODES { WRITE_MODE_APPEND_EXISTING , WRITE_MODE_CREATE_OR_REPLACE }

Functions

MTSTATUS vfs_init (void)
 Initialize the Virtual File System (initializes other filesystem needed services as well)
MTSTATUS vfs_read (const char *filename, uint32_t *file_size_out, void **buffer_out)
 Reads the file into a buffer.
MTSTATUS vfs_write (const char *path, const void *data, uint32_t size, FS_WRITE_MODES write_mode)
 Creates a new file (or opens existing) and writes data to it.
MTSTATUS vfs_delete (const char *path)
 This function deletes the file given to the function from the system.
MTSTATUS vfs_listdir (const char *path, char *listings, size_t max_len)
 Lists the directory given.
MTSTATUS vfs_mkdir (const char *path)
 Creates a new directory.
MTSTATUS vfs_rmdir (const char *path)
 This function deletes the directory given to the function from the system along with its file (marks as deleted).
bool vfs_is_dir_empty (const char *path)
 This function returns if the directory given to the function is empty (e.g, has only '.' and '..' entries / is nonexistent / is deleted)
void vfs_listrootdir (void)
 This function will list the root directory of the main mount device.

Typedef Documentation

◆ FS_DRIVER

typedef struct FS_DRIVER FS_DRIVER

◆ FS_WRITE_MODES

Enumeration Type Documentation

◆ _FS_WRITE_MODES

Enumerator
WRITE_MODE_APPEND_EXISTING 
WRITE_MODE_CREATE_OR_REPLACE 

Definition at line 13 of file vfs.h.

Function Documentation

◆ vfs_delete()

MTSTATUS vfs_delete ( const char * path)

This function deletes the file given to the function from the system.

Parameters
pathFull path to delete file.
Returns
MTSTATUS Status code.

Definition at line 101 of file vfs.c.

◆ vfs_init()

MTSTATUS vfs_init ( void )

Initialize the Virtual File System (initializes other filesystem needed services as well)

Returns
MTSTATUS Status Code

Definition at line 42 of file vfs.c.

◆ vfs_is_dir_empty()

bool vfs_is_dir_empty ( const char * path)

This function returns if the directory given to the function is empty (e.g, has only '.' and '..' entries / is nonexistent / is deleted)

Parameters
pathFull path to dir
Returns
True or false based if empty or not.

Definition at line 129 of file vfs.c.

◆ vfs_listdir()

MTSTATUS vfs_listdir ( const char * path,
char * listings,
size_t max_len )

Lists the directory given.

Parameters
pathPath to directory, e.g "mydir/"
listings[OUT] Pointer to directory listing. (each seperated with a newline character)
max_len[IN] Max size of listings buffer.
Returns
MTSTATUS Status code.

Definition at line 108 of file vfs.c.

◆ vfs_listrootdir()

void vfs_listrootdir ( void )

This function will list the root directory of the main mount device.

Definition at line 136 of file vfs.c.

◆ vfs_mkdir()

MTSTATUS vfs_mkdir ( const char * path)

Creates a new directory.

Parameters
pathThe full path to the new directory
Returns
MTSTATUS Status code.

Definition at line 115 of file vfs.c.

◆ vfs_read()

MTSTATUS vfs_read ( const char * filename,
uint32_t * file_size_out,
void ** buffer_out )

Reads the file into a buffer.

Parameters
filenameThe Filename to read, e.g "file.txt" or "tmp/folder/myfile.txt"
file_size_outA pointer to put the file size in bytes
bufferOutA pointer to put the file buffer in (doesn't need to be dynamically allocated)
Returns
MTSTATUS Status Code.

Definition at line 87 of file vfs.c.

◆ vfs_rmdir()

MTSTATUS vfs_rmdir ( const char * path)

This function deletes the directory given to the function from the system along with its file (marks as deleted).

Parameters
pathFull path to delete directory.
Returns
MTSTATUS Status code.

Definition at line 122 of file vfs.c.

◆ vfs_write()

MTSTATUS vfs_write ( const char * path,
const void * data,
uint32_t size,
FS_WRITE_MODES write_mode )

Creates a new file (or opens existing) and writes data to it.

Parameters
pathThe full path of the file to create
dataA pointer to the data to write.
sizeThe number of bytes to write
write_modeWhether to APPEND or CREATE/REPLACE the file. (in FS_WRITE_MODES enum)
Returns
MTSTATUS Status Code

Definition at line 94 of file vfs.c.