Added possibility to open multiple files with LFS_NO_MALLOC enabled.
This commit is contained in:
committed by
Christopher Haster
parent
f94d233deb
commit
97711d78c4
@@ -1283,7 +1283,7 @@ static int lfs_ctz_traverse(lfs_t *lfs,
|
||||
|
||||
/// Top level file operations ///
|
||||
int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
|
||||
const char *path, int flags) {
|
||||
const char *path, int flags, void *file_buffer) {
|
||||
// deorphan if we haven't yet, needed at most once after poweron
|
||||
if ((flags & 3) != LFS_O_RDONLY && !lfs->deorphaned) {
|
||||
int err = lfs_deorphan(lfs);
|
||||
@@ -1340,7 +1340,10 @@ int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
|
||||
}
|
||||
|
||||
// allocate buffer if needed
|
||||
if (lfs->cfg->file_buffer) {
|
||||
file->cache.block = 0xffffffff;
|
||||
if (file_buffer) {
|
||||
file->cache.buffer = file_buffer;
|
||||
} else if (lfs->cfg->file_buffer) {
|
||||
if (lfs->files) {
|
||||
// already in use
|
||||
return LFS_ERR_NOMEM;
|
||||
|
||||
@@ -334,7 +334,7 @@ int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info);
|
||||
//
|
||||
// Returns a negative error code on failure.
|
||||
int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
|
||||
const char *path, int flags);
|
||||
const char *path, int flags, void *file_buffer);
|
||||
|
||||
// Close a file
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user