From a1b6e2ff898c3ad6b51ace23df1693f3636ed63a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Apr 2024 21:52:31 +0200 Subject: [PATCH] improve filesystem API --- src/fsfw/filesystem/HasFileSystemIF.h | 2 +- src/fsfw_hal/host/HostFilesystem.cpp | 6 +++--- src/fsfw_hal/host/HostFilesystem.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index 4f041135..bffc174d 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -80,7 +80,7 @@ class HasFileSystemIF { virtual bool isDirectory(const char* path) = 0; - virtual bool getFileSize(FilesystemParams params, uint64_t& fileSize) = 0; + virtual ReturnValue_t getFileSize(FilesystemParams params, uint64_t& fileSize) = 0; virtual bool fileExists(FilesystemParams params) = 0; diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index b574c6c0..827dda3d 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -185,10 +185,10 @@ ReturnValue_t HostFilesystem::getBaseFilename(FilesystemParams params, char *nam return returnvalue::OK; } -bool HostFilesystem::getFileSize(FilesystemParams params, uint64_t &fileSize) { +ReturnValue_t HostFilesystem::getFileSize(FilesystemParams params, uint64_t &fileSize) { if (!fileExists(params)) { - return false; + return HasFileSystemIF::FILE_DOES_NOT_EXIST; } fileSize = std::filesystem::file_size(params.path); - return true; + return returnvalue::OK; } diff --git a/src/fsfw_hal/host/HostFilesystem.h b/src/fsfw_hal/host/HostFilesystem.h index fd745e09..5b029abd 100644 --- a/src/fsfw_hal/host/HostFilesystem.h +++ b/src/fsfw_hal/host/HostFilesystem.h @@ -11,7 +11,7 @@ class HostFilesystem : public HasFileSystemIF { ReturnValue_t getBaseFilename(FilesystemParams params, char *nameBuf, size_t maxLen, size_t &baseNameLen) override; - virtual bool getFileSize(FilesystemParams params, uint64_t &fileSize) override; + virtual ReturnValue_t getFileSize(FilesystemParams params, uint64_t &fileSize) override; bool isDirectory(const char *path) override; bool fileExists(FilesystemParams params) override; ReturnValue_t truncateFile(FilesystemParams params) override;