ESP32-P4 OBC Firmware
ESP-IDF firmware for Plant-B CubeSat OBC
 
Loading...
Searching...
No Matches
fs_utils.h File Reference

A collection of useful POSIX wrappers for file / directory handling. More...

#include "esp_log.h"
#include "esp_err.h"
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <stdbool.h>
#include <dirent.h>

Go to the source code of this file.

Typedefs

typedef FILE file_t
 File handle type.
 

Enumerations

enum  f_result_t {
  FR_OK , FR_EOF , FR_DISK_ERR , FR_NO_FILE ,
  FR_BUFFER_TOO_SMALL , FR_INVALID_PARAM
}
 File system operation result codes. More...
 
enum  f_mode_t {
  WRITE_OVERWRITE , WRITE_APPEND , READ , BWRITE_OVERWRITE ,
  BWRITE_APPEND , BREAD
}
 File access and operation modes. More...
 

Functions

bool path_exists (const char *path)
 Check whether a path exists.
 
bool dir_exists (const char *path)
 Check whether a directory exists.
 
bool file_exists (const char *path)
 Check whether a file exists.
 
f_result_t dir_list (const char *path)
 List contents of a directory.
 
f_result_t file_open (file_t **const file, const char *path, f_mode_t mode)
 Open a file with the specified mode and initilize a file descriptor.
 
f_result_t file_close (file_t **file)
 Close an open file from its descriptor.
 
f_result_t file_remove (const char *path)
 Remove a file from the file system.
 
f_result_t file_writeline (file_t *const file, const char *const restrict str)
 Write a null-terminated string to an open file.
 
f_result_t file_write (file_t *const file, const void *const restrict data, size_t sz, size_t n)
 Write raw data to an open file.
 
f_result_t file_readline (file_t *const file, char *const restrict buf, size_t n)
 Read a newline-terminated string from an open file.
 
f_result_t file_read (file_t *const file, void *const restrict buf, size_t sz, size_t n)
 Read raw data from an open file.
 

Detailed Description

A collection of useful POSIX wrappers for file / directory handling.

Author
Adrien Chevrier

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Version
0.1
Date
2026-02-05