F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Os::FileSystem Namespace Reference

Enumerations

enum  Status {
  OP_OK , ALREADY_EXISTS , NO_SPACE , NO_PERMISSION ,
  NOT_DIR , IS_DIR , NOT_EMPTY , INVALID_PATH ,
  FILE_LIMIT , BUSY , OTHER_ERROR
}
 

Functions

Status createDirectory (const char *path)
 create a new directory at location path More...
 
Status removeDirectory (const char *path)
 remove a directory at location path More...
 
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 Directory.hpp More...
 
Status removeFile (const char *path)
 removes a file at location path More...
 
Status moveFile (const char *originPath, const char *destPath)
 
Status handleFileError (File::Status fileStatus)
 
Status copyFile (const char *originPath, const char *destPath)
 moves a file from origin to destination More...
 
Status getFileSize (const char *path, FwSizeType &size)
 
Status changeWorkingDirectory (const char *path)
 move current directory to path More...
 
Status getFileCount (const char *directory, U32 &fileCount)
 counts the number of files in the given directory More...
 
Status appendFile (const char *originPath, const char *destPath, bool createMissingDest=false)
 copies a file from origin to destination More...
 
Status getFreeSpace (const char *path, FwSizeType &totalBytes, FwSizeType &freeBytes)
 get FS free and total space in bytes on filesystem containing path More...
 
Status getFileSize (const char *path, FwSignedSizeType &size)
 append file origin to destination file. If boolean true, creates a brand new file if the destination doesn't exist. More...
 
Status initAndCheckFileStats (const char *filePath, struct stat *fileInfo=nullptr)
 
Status copyFileData (File &source, File &destination, FwSignedSizeType size)
 

Enumeration Type Documentation

◆ Status

Enumerator
OP_OK 

Operation was successful.

ALREADY_EXISTS 

File already exists.

NO_SPACE 

No space left.

NO_PERMISSION 

No permission to write.

NOT_DIR 

Path is not a directory.

IS_DIR 

Path is a directory.

NOT_EMPTY 

directory is not empty

INVALID_PATH 

Path is too long, too many sym links, doesn't exist, ect.

FILE_LIMIT 

Too many files or links.

BUSY 

Operand is in use by the system or by a process.

OTHER_ERROR 

other OS-specific error

Definition at line 14 of file FileSystem.hpp.

Function Documentation

◆ appendFile()

Status Os::FileSystem::appendFile ( const char *  originPath,
const char *  destPath,
bool  createMissingDest = false 
)

copies a file from origin to destination

< gets the size of the file (in bytes) at location path

< gets the size of the file (in bytes) at location path

Definition at line 49 of file FileSystem.cpp.

◆ changeWorkingDirectory()

Status Os::FileSystem::changeWorkingDirectory ( const char *  path)

move current directory to path

Definition at line 42 of file FileSystem.cpp.

◆ copyFile()

Status Os::FileSystem::copyFile ( const char *  originPath,
const char *  destPath 
)

moves a file from origin to destination

< gets the size of the file (in bytes) at location path

< gets the size of the file (in bytes) at location path

Definition at line 34 of file FileSystem.cpp.

◆ copyFileData()

Status Os::FileSystem::copyFileData ( File source,
File destination,
FwSignedSizeType  size 
)

A helper function that writes all the file information in the source file to the destination file (replaces/appends to end/etc. depending on destination file mode).

Files must already be open and will remain open after this function completes.

Parameters
sourceFile to copy data from
destinationFile to copy data to
sizeThe number of bytes to copy

Definition at line 320 of file FileSystem.cpp.

◆ createDirectory()

Status Os::FileSystem::createDirectory ( const char *  path)

create a new directory at location path

Definition at line 8 of file FileSystem.cpp.

◆ getFileCount()

Status Os::FileSystem::getFileCount ( const char *  directory,
U32 &  fileCount 
)

counts the number of files in the given directory

Definition at line 46 of file FileSystem.cpp.

◆ getFileSize() [1/2]

Status Os::FileSystem::getFileSize ( const char *  path,
FwSignedSizeType size 
)

append file origin to destination file. If boolean true, creates a brand new file if the destination doesn't exist.

gets the size of the file (in bytes) at location path

Definition at line 438 of file FileSystem.cpp.

◆ getFileSize() [2/2]

Status Os::FileSystem::getFileSize ( const char *  path,
FwSizeType size 
)

Definition at line 38 of file FileSystem.cpp.

◆ getFreeSpace()

Status Os::FileSystem::getFreeSpace ( const char *  path,
FwSizeType totalBytes,
FwSizeType freeBytes 
)

get FS free and total space in bytes on filesystem containing path

Definition at line 52 of file FileSystem.cpp.

◆ handleFileError()

Status Os::FileSystem::handleFileError ( File::Status  fileStatus)

Definition at line 30 of file FileSystem.cpp.

◆ initAndCheckFileStats()

Status Os::FileSystem::initAndCheckFileStats ( const char *  filePath,
struct stat *  fileInfo = nullptr 
)

A helper function that returns an "OP_OK" status if the given file exists and can be read from, otherwise returns an error status.

If provided, will also initialize the given stat struct with file information.

Definition at line 272 of file FileSystem.cpp.

◆ moveFile()

Status Os::FileSystem::moveFile ( const char *  originPath,
const char *  destPath 
)

Definition at line 25 of file FileSystem.cpp.

◆ readDirectory()

Status Os::FileSystem::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 Directory.hpp

Definition at line 16 of file FileSystem.cpp.

◆ removeDirectory()

Status Os::FileSystem::removeDirectory ( const char *  path)

remove a directory at location path

Definition at line 12 of file FileSystem.cpp.

◆ removeFile()

Status Os::FileSystem::removeFile ( const char *  path)

removes a file at location path

Definition at line 21 of file FileSystem.cpp.