Hello, I am trying to delete a file with remove function. The file is successfully deleted but the free space of my storage doesn't change… Any ideas ?
Thanks
remove file doesn"t free space
-
- Posts: 361
- Joined: Mon Jan 04, 2021 2:06 pm
Re: remove file doesn"t free space
Hi,
Can you provide more information about? Can you share the code, IDF version, etc...?
We can try to help you if you provide us more details about it !
Can you provide more information about? Can you share the code, IDF version, etc...?
We can try to help you if you provide us more details about it !
-
- Posts: 17
- Joined: Mon Dec 21, 2020 10:29 am
Re: remove file doesn"t free space
here is the code where I delete the file :
int del = remove(g_day_stamp_comparaison);
if (!del)
{
ESP_LOGI(tag, "oldest file has been deleted sucessfully");
}
and here is where I check the free space :
static void storageModule_get_fatfs_usage(size_t *out_total_bytes, size_t *out_free_bytes)
{
FATFS *fs;
size_t free_clusters;
int res = f_getfree("0:", &free_clusters, &fs);
assert(res == FR_OK);
size_t total_sectors = (fs->n_fatent - 2) * fs->csize;
size_t free_sectors = free_clusters * fs->csize;
// assuming the total size is < 4GiB, should be true for SPI Flash
if (out_total_bytes != NULL)
{
*out_total_bytes = total_sectors * fs->ssize;
}
if (out_free_bytes != NULL)
{
*out_free_bytes = free_sectors * fs->ssize;
}
}
int del = remove(g_day_stamp_comparaison);
if (!del)
{
ESP_LOGI(tag, "oldest file has been deleted sucessfully");
}
and here is where I check the free space :
static void storageModule_get_fatfs_usage(size_t *out_total_bytes, size_t *out_free_bytes)
{
FATFS *fs;
size_t free_clusters;
int res = f_getfree("0:", &free_clusters, &fs);
assert(res == FR_OK);
size_t total_sectors = (fs->n_fatent - 2) * fs->csize;
size_t free_sectors = free_clusters * fs->csize;
// assuming the total size is < 4GiB, should be true for SPI Flash
if (out_total_bytes != NULL)
{
*out_total_bytes = total_sectors * fs->ssize;
}
if (out_free_bytes != NULL)
{
*out_free_bytes = free_sectors * fs->ssize;
}
}
Who is online
Users browsing this forum: Abisha, Bing [Bot] and 248 guests