mirror of https://github.com/ARMmbed/mbed-os.git
Added implementation of FileSystem::reformat
parent
11440f6018
commit
adbd0290f8
|
@ -223,6 +223,31 @@ int LittleFileSystem::format(BlockDevice *bd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LittleFileSystem::reformat(BlockDevice *bd) {
|
||||
if (_bd) {
|
||||
if (!bd) {
|
||||
bd = _bd;
|
||||
}
|
||||
|
||||
int err = unmount();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bd) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int err = LittleFileSystem::format(bd,
|
||||
_read_size, _prog_size, _block_size, _lookahead);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return mount(bd);
|
||||
}
|
||||
|
||||
int LittleFileSystem::remove(const char *filename) {
|
||||
int err = lfs_remove(&_lfs, filename);
|
||||
return lfs_toerror(err);
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
lfs_size_t lookahead=MBED_LFS_LOOKAHEAD);
|
||||
virtual ~LittleFileSystem();
|
||||
|
||||
/** Formats a logical drive, FDISK partitioning rule.
|
||||
/** Formats a block device with the LittleFileSystem
|
||||
*
|
||||
* The block device to format should be mounted when this function is called.
|
||||
*
|
||||
|
@ -107,6 +107,18 @@ public:
|
|||
*/
|
||||
virtual int unmount();
|
||||
|
||||
/** Reformats a filesystem, results in an empty and mounted filesystem
|
||||
*
|
||||
* @param bd
|
||||
* BlockDevice to reformat and mount. If NULL, the mounted
|
||||
* block device will be used.
|
||||
* Note: if mount fails, bd must be provided.
|
||||
* Default: NULL
|
||||
*
|
||||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual int reformat(BlockDevice *bd);
|
||||
|
||||
/** Remove a file from the filesystem.
|
||||
*
|
||||
* @param path The name of the file to remove.
|
||||
|
|
Loading…
Reference in New Issue