mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 16:14:16 +01:00 
			
		
		
		
	fixup for 5c87b6864
				
					
				
			Add in lfs_removeall(...) and lfs_rename_with_removeall(...).
This commit is contained in:
		
							
								
								
									
										36
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -5067,6 +5067,24 @@ int lfs_remove(lfs_t *lfs, const char *path) { | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #ifndef LFS_READONLY | ||||
| int lfs_removeall(lfs_t *lfs, const char *path) { | ||||
|     int err = LFS_LOCK(lfs->cfg); | ||||
|     if (err) { | ||||
|         return err; | ||||
|     } | ||||
|     LFS_TRACE("lfs_removeall(%p, \"%s\")", (void*)lfs, path); | ||||
|  | ||||
|     // Note: We pass in a helper pointer here so that this extra | ||||
|     //       logic can be dropped if it is never referenced | ||||
|     err = lfs_rawremove(lfs, path, lfs_dir_prep_remove_nonempty_folders); | ||||
|  | ||||
|     LFS_TRACE("lfs_removeall -> %d", err); | ||||
|     LFS_UNLOCK(lfs->cfg); | ||||
|     return err; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #ifndef LFS_READONLY | ||||
| int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) { | ||||
|     int err = LFS_LOCK(lfs->cfg); | ||||
| @@ -5083,6 +5101,24 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) { | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #ifndef LFS_READONLY | ||||
| int lfs_rename_with_removeall(lfs_t *lfs, const char *oldpath, const char *newpath) { | ||||
|     int err = LFS_LOCK(lfs->cfg); | ||||
|     if (err) { | ||||
|         return err; | ||||
|     } | ||||
|     LFS_TRACE("lfs_rename(%p, \"%s\", \"%s\")", (void*)lfs, oldpath, newpath); | ||||
|  | ||||
|     // Note: We pass in a helper pointer here so that this extra | ||||
|     //       logic can be dropped if it is never referenced | ||||
|     err = lfs_rawrename(lfs, oldpath, newpath, lfs_dir_prep_remove_nonempty_folders); | ||||
|  | ||||
|     LFS_TRACE("lfs_rename -> %d", err); | ||||
|     LFS_UNLOCK(lfs->cfg); | ||||
|     return err; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info) { | ||||
|     int err = LFS_LOCK(lfs->cfg); | ||||
|     if (err) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user