This commit is contained in:
2026-02-26 15:44:43 +01:00
parent b8b3e6ea44
commit 5934bba4af
7 changed files with 159 additions and 16 deletions

View File

@@ -79,16 +79,19 @@ int fs_pm_flash_resume(void)
int fs_pm_open(struct fs_file_t *file, const char *path, fs_mode_t mode)
{
LOG_DBG("PM Opening file '%s' with mode 0x%02x", path, mode);
fs_pm_flash_resume();
int rc = fs_open(file, path, mode);
if (rc == 0)
if (rc < 0)
{
fs_pm_flash_resume();
fs_pm_flash_suspend();
}
return rc;
}
int fs_pm_close(struct fs_file_t *file)
{
LOG_DBG("PM Closing file");
int rc = fs_close(file);
if (rc == 0)
{
@@ -99,20 +102,44 @@ int fs_pm_close(struct fs_file_t *file)
int fs_pm_opendir(struct fs_dir_t *dirp, const char *path)
{
LOG_DBG("PM Opening directory '%s'", path);
fs_pm_flash_resume();
int rc = fs_opendir(dirp, path);
if (rc == 0)
if (rc < 0)
{
fs_pm_flash_resume();
fs_pm_flash_suspend();
}
return rc;
}
int fs_pm_closedir(struct fs_dir_t *dirp)
{
LOG_DBG("PM Closing directory");
int rc = fs_closedir(dirp);
if (rc == 0)
{
fs_pm_flash_suspend();
}
return rc;
}
int fs_pm_unlink(const char *path)
{
LOG_DBG("PM Unlinking file '%s'", path);
fs_pm_flash_resume();
int rc = fs_unlink(path);
if (rc < 0)
{
fs_pm_flash_suspend();
}
return rc;
}
int fs_pm_statvfs(const char *path, struct fs_statvfs *stat)
{
LOG_DBG("PM Getting filesystem stats for '%s'", path);
fs_pm_flash_resume();
int rc = fs_statvfs(path, stat);
fs_pm_flash_suspend();
return rc;
}