F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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
 
Status removeDirectory (const char *path)
 remove a directory at location path
 
Status readDirectory (const char *path, const U32 maxNum, Fw::String fileArray[])
 
Status removeFile (const char *path)
 removes a file at location path
 
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
 
Status getFileSize (const char *path, FwSizeType &size)
 append file origin to destination file. If boolean true, creates a brand new file if the destination doesn't exist.
 
Status changeWorkingDirectory (const char *path)
 move current directory to path
 
Status getFileCount (const char *directory, U32 &fileCount)
 counts the number of files in the given directory
 
Status appendFile (const char *originPath, const char *destPath, bool createMissingDest=false)
 copies a file from origin to destination
 
Status getFreeSpace (const char *path, FwSizeType &totalBytes, FwSizeType &freeBytes)
 get FS free and total space in bytes on filesystem containing path
 
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
 
Status initAndCheckFileStats (const char *filePath, struct stat *fileInfo=nullptr)
 
Status copyFileData (File source, File destination, FwSizeType 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 47 of file FileSystem.cpp.

◆ changeWorkingDirectory()

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

move current directory to path

Definition at line 40 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 32 of file FileSystem.cpp.

◆ copyFileData()

Status Os::FileSystem::copyFileData ( File  source,
File  destination,
FwSizeType  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 44 of file FileSystem.cpp.

◆ getFileSize()

Status Os::FileSystem::getFileSize ( const char *  path,
FwSizeType 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 36 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 50 of file FileSystem.cpp.

◆ handleFileError()

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

Definition at line 28 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 23 of file FileSystem.cpp.

◆ readDirectory() [1/2]

Status Os::FileSystem::readDirectory ( const char *  path,
const U32  maxNum,
Fw::String  fileArray[] 
)

Definition at line 16 of file FileSystem.cpp.

◆ readDirectory() [2/2]

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 99 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 19 of file FileSystem.cpp.