MicrOS
micros_filesystem.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "micros_interrupts.h"

Go to the source code of this file.

Classes

struct  micros_filesystem_time
 Structure representing create/modify/access time of file or directory. More...
 
struct  micros_filesystem_file_info
 Structure representing information about the specified file. More...
 
struct  micros_filesystem_directory_info
 Structure representing information about the specified directory. More...
 

Functions

bool micros_filesystem_get_file_info (const char *path, micros_filesystem_file_info *file_info)
 Gets information about the file with path specified in parameter. More...
 
bool micros_filesystem_get_directory_info (const char *path, micros_filesystem_directory_info *directory_info)
 Gets information about the directory with path specified in parameter. More...
 
bool micros_filesystem_read_file (const char *path, uint8_t *buffer, const uint32_t start_index, const uint32_t length)
 Reads content from the file. More...
 
uint32_t micros_filesystem_get_entries_count_in_directory (const char *path)
 Gets entries count in the directory. More...
 
bool micros_filesystem_get_entries_in_directory (const char *path, char **entries)
 Gets pathes of the entries in the directory. More...
 
bool micros_filesystem_is_file (const char *path)
 Check if the specified entry is a file. More...
 
bool micros_filesystem_is_directory (const char *path)
 Check if the specified entry is a directory. More...
 
bool micros_filesystem_create_file (const char *path)
 Creates file. More...
 
bool micros_filesystem_create_directory (const char *path)
 Creates directory. More...
 
bool micros_filesystem_delete_file (const char *path)
 Deletes file. More...
 
bool micros_filesystem_delete_directory (const char *path)
 Deletes directory. More...
 
bool micros_filesystem_rename_file (const char *path, const char *new_name)
 Renames file. More...
 
bool micros_filesystem_rename_directory (const char *path, const char *new_name)
 Renames directory. More...
 
bool micros_filesystem_save_to_file (const char *path, const char *buffer, const int size)
 Saves content stored in the buffer to the specified file. More...
 
bool micros_filesystem_append_to_file (const char *path, const char *buffer, const int size)
 Appends content stored in the buffer to the end of the specified file. More...
 
bool micros_filesystem_file_exists (const char *path)
 Checks if file with the specified path exists. More...
 
bool micros_filesystem_directory_exists (const char *path)
 Checks if directory with the specified path exists. More...
 
int micros_filesystem_get_free_space (const char partition_symbol)
 Gets free space on the specified partition. More...
 
int micros_filesystem_get_total_space (const char partition_symbol)
 Gets total space on the specified partition. More...
 

Function Documentation

◆ micros_filesystem_append_to_file()

bool micros_filesystem_append_to_file ( const char *  path,
const char *  buffer,
const int  size 
)

Appends content stored in the buffer to the end of the specified file.

Appends content stored in the buffer to the end of the specified file and returns flag indicating success.

Parameters
pathPath to the file.
bufferBuffer with content to save.
sizeBuffer size.
Returns
True if the content has been saved with success, otherwise false.

◆ micros_filesystem_create_directory()

bool micros_filesystem_create_directory ( const char *  path)

Creates directory.

Creates directory with the specified path.

Parameters
pathPath to the new directory.
Returns
True if the directory has been creates with success, otherwise false.

◆ micros_filesystem_create_file()

bool micros_filesystem_create_file ( const char *  path)

Creates file.

Creates file with the specified path.

Parameters
pathPath to the new file.
Returns
True if the file has been creates with success, otherwise false.

◆ micros_filesystem_delete_directory()

bool micros_filesystem_delete_directory ( const char *  path)

Deletes directory.

Deletes directory with the specified path.

Parameters
pathPath to the directory.
Returns
True if the directory has been deleted with success, otherwise false.

◆ micros_filesystem_delete_file()

bool micros_filesystem_delete_file ( const char *  path)

Deletes file.

Deletes file with the specified path.

Parameters
pathPath to the file.
Returns
True if the file has been deleted with success, otherwise false.

◆ micros_filesystem_directory_exists()

bool micros_filesystem_directory_exists ( const char *  path)

Checks if directory with the specified path exists.

Checks if directory with the specified path exists and returns corresponding flag

Parameters
pathPath to the directory.
Returns
True if the directory exists, otherwise false.

◆ micros_filesystem_file_exists()

bool micros_filesystem_file_exists ( const char *  path)

Checks if file with the specified path exists.

Checks if file with the specified path exists and returns corresponding flag

Parameters
pathPath to the file.
Returns
True if the file exists, otherwise false.

◆ micros_filesystem_get_directory_info()

bool micros_filesystem_get_directory_info ( const char *  path,
micros_filesystem_directory_info directory_info 
)

Gets information about the directory with path specified in parameter.

Gets information about the directory with path specified in parameter and fills structure.

Parameters
pathPath to the directory.
directory_infoStructure which will be filled.
Returns
True if directory exists and structure has been filled, otherwise false.

◆ micros_filesystem_get_entries_count_in_directory()

uint32_t micros_filesystem_get_entries_count_in_directory ( const char *  path)

Gets entries count in the directory.

Gets entries count (files and directories) in the directory.

Parameters
pathPath to the directory.
Returns
Entries count.

◆ micros_filesystem_get_entries_in_directory()

bool micros_filesystem_get_entries_in_directory ( const char *  path,
char **  entries 
)

Gets pathes of the entries in the directory.

Gets pathes of the entries in the directory and stores them in the passed buffer.

Parameters
pathPath to the directory.
entriesBuffer where the pathes will be stored.
Returns
True if the target directory was found, otherwise false.

◆ micros_filesystem_get_file_info()

bool micros_filesystem_get_file_info ( const char *  path,
micros_filesystem_file_info file_info 
)

Gets information about the file with path specified in parameter.

Gets information about the file with path specified in parameter and fills structure.

Parameters
pathPath to the file.
file_infoStructure which will be filled.
Returns
True if file exists and structure has been filled, otherwise false.

◆ micros_filesystem_get_free_space()

int micros_filesystem_get_free_space ( const char  partition_symbol)

Gets free space on the specified partition.

Gets free space on the specified partition (in bytes).

Parameters
partition_symbolPartition symbol.
Returns
Free space in bytes.

◆ micros_filesystem_get_total_space()

int micros_filesystem_get_total_space ( const char  partition_symbol)

Gets total space on the specified partition.

Gets total space on specified partition (in bytes).

Parameters
partition_symbolPartition symbol.
Returns
Total space in bytes.

◆ micros_filesystem_is_directory()

bool micros_filesystem_is_directory ( const char *  path)

Check if the specified entry is a directory.

Check if the specified entry is a directory and returns corresponding flag.

Parameters
pathPath to the entry.
Returns
True if the specified entry is a directory, otherwise false.

◆ micros_filesystem_is_file()

bool micros_filesystem_is_file ( const char *  path)

Check if the specified entry is a file.

Check if the specified entry is a file and returns corresponding flag.

Parameters
pathPath to the entry.
Returns
True if the specified entry is a directory, otherwise false.

◆ micros_filesystem_read_file()

bool micros_filesystem_read_file ( const char *  path,
uint8_t *  buffer,
const uint32_t  start_index,
const uint32_t  length 
)

Reads content from the file.

Reads content from the file and stores data in the buffer passed in the parameter.

Parameters
pathPath to the directory.
bufferBuffer where the read data will be stored. Size must be equal or bigger than length.
start_indexPosition where the reading will be started.
lengthRequested size of the read data.
Returns
True if file was found and data was read, otherwise false.

◆ micros_filesystem_rename_directory()

bool micros_filesystem_rename_directory ( const char *  path,
const char *  new_name 
)

Renames directory.

Renames directory with the specified path.

Parameters
pathPath to the directory.
new_nameNew name of the directory (Without leading path).
Returns
True if the directory has been renamed with success, otherwise false.

◆ micros_filesystem_rename_file()

bool micros_filesystem_rename_file ( const char *  path,
const char *  new_name 
)

Renames file.

Renames file with the specified path.

Parameters
pathPath to the file.
new_nameNew name of the file (Without leading path).
Returns
True if the file has been renamed with success, otherwise false.

◆ micros_filesystem_save_to_file()

bool micros_filesystem_save_to_file ( const char *  path,
const char *  buffer,
const int  size 
)

Saves content stored in the buffer to the specified file.

Saves content stored in the buffer to the specified file and returns flag indicating success. If file is not empty, then old data is overwrited.

Parameters
pathPath to the file.
bufferBuffer with content to save.
sizeBuffer size.
Returns
True if the content has been saved with success, otherwise false.