whiskers 0.2.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
72
73#ifndef W_HAL_FILE_H
74#define W_HAL_FILE_H
75
76#include "shared.h"
77
83HAL_ERROR ff_err_to_hal(uint32_t ff_err);
84/* If return type is bool, that means true on success false on failure and fp->errno is set */
114bool ffopen(const char *filename, const char *mode, _FILE *fp);
121bool ffclose(_FILE *fp);
122/* read and write return amount of bytes read/wrote. if value != buf_size then an error occured! */
136uint32_t ffread(_FILE *fp, void* buf, uint32_t buf_size);
150uint32_t ffwrite(_FILE *fp, const void* buf, uint32_t buf_size);
158bool ffseek(_FILE *fp, long offset); /* Can be negative or positive. if negative goes past zero then it sets the fp to zero */
159
169bool ffexpand(_FILE *fp, uint64_t size);
176uint32_t fftell(_FILE *fp);
186bool ffstat(const char *path, _FILE *file_info);
194bool ffunlink(const char *path, _FILE *fp); /* fp passed just for errno */
195
196/* Directory stuff */
204bool ffmkdir(const char *path, _DIR *dp); /* dp really here just for errno */
212bool fdstat(const char *path, _DIR *dir_info); /* Same as fstat but for dirs */
226bool ffopendir(_DIR *dp, const char *path);
233bool ffclosedir(_DIR *dp);
245bool ffreaddir(_DIR *dp, _FILE *file_info);
246
247#endif
bool ffexpand(_FILE *fp, uint64_t size)
Expands/Allocates a continous chunk of memory of n size.
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 fdstat(const char *path, _DIR *dir_info)
Check whether the directory exists and gets the information about the directory.
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:31