is directory is fallible now

This commit is contained in:
Robin Müller 2024-05-24 14:29:42 +02:00
parent a1b6e2ff89
commit 312858eb1c
4 changed files with 10 additions and 9 deletions

View File

@ -310,7 +310,9 @@ ReturnValue_t cfdp::DestHandler::startTransaction(const MetadataPduReader& reade
FilesystemParams fparams(transactionParams.destName.data());
// handling to allow only specifying target directory. Example:
// Source path /test/hello.txt, dest path /tmp -> dest path /tmp/hello.txt
if (destParams.user.vfs.isDirectory(transactionParams.destName.data())) {
bool isDirectory = false;
result = destParams.user.vfs.isDirectory(transactionParams.destName.data(), isDirectory);
if (result == returnvalue::OK && isDirectory) {
result = tryBuildingAbsoluteDestName(destNameSize);
if (result != OK) {
return result;

View File

@ -58,11 +58,7 @@ class HasFileSystemIF {
static constexpr ReturnValue_t DIRECTORY_ALREADY_EXISTS = MAKE_RETURN_CODE(22);
static constexpr ReturnValue_t NOT_A_DIRECTORY = MAKE_RETURN_CODE(23);
static constexpr ReturnValue_t DIRECTORY_NOT_EMPTY = MAKE_RETURN_CODE(24);
//! [EXPORT] : P1: Sequence number missing
static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_WRITE = MAKE_RETURN_CODE(30);
//! [EXPORT] : P1: Sequence number missing
static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_READ = MAKE_RETURN_CODE(31);
static constexpr ReturnValue_t ELEMENT_DOES_NOT_EXIST = MAKE_RETURN_CODE(25);
virtual ~HasFileSystemIF() = default;
@ -78,7 +74,7 @@ class HasFileSystemIF {
virtual ReturnValue_t getBaseFilename(FilesystemParams params, char* nameBuf, size_t maxLen,
size_t& baseNameLen) = 0;
virtual bool isDirectory(const char* path) = 0;
virtual ReturnValue_t isDirectory(const char* path, bool& isDirectory) = 0;
virtual ReturnValue_t getFileSize(FilesystemParams params, uint64_t& fileSize) = 0;

View File

@ -170,7 +170,10 @@ ReturnValue_t HostFilesystem::truncateFile(FilesystemParams params) {
return returnvalue::OK;
}
bool HostFilesystem::isDirectory(const char *path) { return filesystem::is_directory(path); }
ReturnValue_t HostFilesystem::isDirectory(const char *path, bool &isDirectory) {
isDirectory = filesystem::is_directory(path);
return returnvalue::OK;
}
ReturnValue_t HostFilesystem::getBaseFilename(FilesystemParams params, char *nameBuf, size_t maxLen,
size_t &baseNameLen) {

View File

@ -12,7 +12,7 @@ class HostFilesystem : public HasFileSystemIF {
ReturnValue_t getBaseFilename(FilesystemParams params, char *nameBuf, size_t maxLen,
size_t &baseNameLen) override;
virtual ReturnValue_t getFileSize(FilesystemParams params, uint64_t &fileSize) override;
bool isDirectory(const char *path) override;
ReturnValue_t isDirectory(const char *path, bool &isDirectory) override;
bool fileExists(FilesystemParams params) override;
ReturnValue_t truncateFile(FilesystemParams params) override;
ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override;