whiskers 0.4.0
RP2350 BadUSB Tool
Loading...
Searching...
No Matches
file.h
Go to the documentation of this file.
1/* Copyright (c) 2026 Zane A. Maples
2 Licensed under the MIT license. See LICENSE in the main repository for more information. */
3
76
77#ifndef W_HAL_FILE_H
78#define W_HAL_FILE_H
79
80#include "shared.h"
81
87HAL_ERROR ff_err_to_hal(uint32_t ff_err);
88/* If return type is bool, that means true on success false on failure and fp->errno is set */
118bool ffopen(const char *filename, const char *mode, _FILE *fp);
128_FILE * ffget__FILE_from_fd(uint32_t fd);
138_DIR * ffget__DIR_from_dd(uint32_t dd);
145bool ffclose(_FILE *fp);
146/* read and write return amount of bytes read/wrote. if value != buf_size then an error occured! */
160uint32_t ffread(_FILE *fp, void* buf, uint32_t buf_size);
168bool ffgets(_FILE *fp, char *buf, uint32_t buf_size);
182uint32_t ffwrite(_FILE *fp, const void* buf, uint32_t buf_size);
191bool ffseek(_FILE *fp, long offset); /* Can be negative or positive. if negative goes past zero then it sets the fp to zero */
192
202bool ffexpand(_FILE *fp, uint32_t size);
209uint32_t fftell(_FILE *fp);
219bool ffstat(const char *path, _FILE *file_info);
226uint32_t ffsize(_FILE *fp);
234bool ffunlink(const char *path, _FILE *fp); /* fp passed just for errno */
235
236/* Directory stuff */
244bool ffmkdir(const char *path, _DIR *dp); /* dp really here just for errno */
252bool fdstat(const char *path, _DIR *dir_info); /* Same as fstat but for dirs */
266bool ffopendir(_DIR *dp, const char *path);
273bool ffclosedir(_DIR *dp);
285bool ffreaddir(_DIR *dp, _FILE *file_info);
286
287#endif
_FILE * ffget__FILE_from_fd(uint32_t fd)
Get's a _FILE pointer from a passed in file descriptor.
_DIR * ffget__DIR_from_dd(uint32_t dd)
Get's a _DIR pointer from a passed in directory descriptor.
uint32_t ffsize(_FILE *fp)
Returns the size of the specified file.
bool ffclose(_FILE *fp)
Closes a file.
bool ffstat(const char *path, _FILE *file_info)
Checks whether the file exists and gets the information on the file.
bool ffmkdir(const char *path, _DIR *dp)
Creates a new directory.
uint32_t ffwrite(_FILE *fp, const void *buf, uint32_t buf_size)
Writes data to the file at it's internal file position.
bool ffreaddir(_DIR *dp, _FILE *file_info)
Reads a directory object (file).
HAL_ERROR ff_err_to_hal(uint32_t ff_err)
Converts an internal FatFS error to a HAL error. This is only used internally.
bool ffunlink(const char *path, _FILE *fp)
Deletes file/directory at path.
bool ffopen(const char *filename, const char *mode, _FILE *fp)
Opens a file at filename with certain access modifiers.
uint32_t ffread(_FILE *fp, void *buf, uint32_t buf_size)
Reads data from the file at it's internal file position.
bool ffclosedir(_DIR *dp)
Closes the _DIR object.
bool ffgets(_FILE *fp, char *buf, uint32_t buf_size)
Reads a string out into buf until it reaches a new line or \0.
bool fdstat(const char *path, _DIR *dir_info)
Check whether the directory exists and gets the information about the directory.
bool ffexpand(_FILE *fp, uint32_t size)
Expands/Allocates a continous chunk of memory of n size.
bool ffseek(_FILE *fp, long offset)
Sets the file position for the specified file.
uint32_t fftell(_FILE *fp)
Gets the current file position the file is at.
bool ffopendir(_DIR *dp, const char *path)
Opens the dir inside the _DIR object.
Shared structs, error codes, and functions for all HAL files.
uint8_t HAL_ERROR
This type represents a HAL_* error. See the defines in the file to read up on them.
Definition shared.h:28