F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
FileSystem.hpp
Go to the documentation of this file.
1 #ifndef _FileSystem_hpp_
2 #define _FileSystem_hpp_
3 
4 #include <FpConfig.hpp>
5 #include <Fw/Types/String.hpp>
6 
7 #define FILE_SYSTEM_CHUNK_SIZE (256u)
8 
9 namespace Os {
10 
11  // This namespace encapsulates a very simple file system interface that has the most often-used features.
12  namespace FileSystem {
13 
14  typedef enum {
24  BUSY,
26  } Status;
27 
28  Status createDirectory(const char* path);
29  Status removeDirectory(const char* path);
30  Status readDirectory(const char* path, const U32 maxNum, Fw::String fileArray[], U32& numFiles);
31  Status removeFile(const char* path);
32  Status moveFile(const char* originPath, const char* destPath);
33  Status copyFile(const char* originPath, const char* destPath);
34  Status appendFile(const char* originPath, const char* destPath, bool createMissingDest=false);
35  Status getFileSize(const char* path, FwSignedSizeType& size);
36  Status getFileCount(const char* directory, U32& fileCount);
37  Status changeWorkingDirectory(const char* path);
38  Status getFreeSpace(const char* path, FwSizeType& totalBytes, FwSizeType& freeBytes);
39  }
40 
41 }
42 
43 #endif
PlatformSignedSizeType FwSignedSizeType
Definition: FpConfig.h:25
PlatformSizeType FwSizeType
Definition: FpConfig.h:30
C++-compatible configuration header for fprime configuration.
Status getFileCount(const char *directory, U32 &fileCount)
counts the number of files in the given directory
Definition: FileSystem.cpp:46
Status getFreeSpace(const char *path, FwSizeType &totalBytes, FwSizeType &freeBytes)
get FS free and total space in bytes on filesystem containing path
Definition: FileSystem.cpp:52
Status createDirectory(const char *path)
create a new directory at location path
Definition: FileSystem.cpp:8
Status moveFile(const char *originPath, const char *destPath)
Definition: FileSystem.cpp:25
Status getFileSize(const char *path, FwSizeType &size)
Definition: FileSystem.cpp:38
Status changeWorkingDirectory(const char *path)
move current directory to path
Definition: FileSystem.cpp:42
Status appendFile(const char *originPath, const char *destPath, bool createMissingDest)
copies a file from origin to destination
Definition: FileSystem.cpp:49
@ OP_OK
Operation was successful.
Definition: FileSystem.hpp:15
@ NOT_DIR
Path is not a directory.
Definition: FileSystem.hpp:19
@ ALREADY_EXISTS
File already exists.
Definition: FileSystem.hpp:16
@ NO_PERMISSION
No permission to write.
Definition: FileSystem.hpp:18
@ IS_DIR
Path is a directory.
Definition: FileSystem.hpp:20
@ INVALID_PATH
Path is too long, too many sym links, doesn't exist, ect.
Definition: FileSystem.hpp:22
@ FILE_LIMIT
Too many files or links.
Definition: FileSystem.hpp:23
@ OTHER_ERROR
other OS-specific error
Definition: FileSystem.hpp:25
@ NOT_EMPTY
directory is not empty
Definition: FileSystem.hpp:21
@ NO_SPACE
No space left.
Definition: FileSystem.hpp:17
@ BUSY
Operand is in use by the system or by a process.
Definition: FileSystem.hpp:24
Status copyFile(const char *originPath, const char *destPath)
moves a file from origin to destination
Definition: FileSystem.cpp:34
Status removeDirectory(const char *path)
remove a directory at location path
Definition: FileSystem.cpp:12
Status removeFile(const char *path)
removes a file at location path
Definition: FileSystem.cpp:21
Status readDirectory(const char *path, const U32 maxNum, Fw::String fileArray[], U32 &numFiles)
read the contents of a directory. Size of fileArray should be maxNum. Cleaner implementation found in...
Definition: FileSystem.cpp:16