 |
F´ Flight Software - C/C++ Documentation
NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
|
Go to the documentation of this file.
14 #include <sys/statvfs.h>
18 namespace FileSystem {
25 int mkStat = ::mkdir(path);
27 int mkStat = ::mkdir(path,S_IRWXU);
69 if (::rmdir(path) == -1) {
108 struct dirent *direntData =
NULL;
114 if((dirPtr = ::opendir(path)) ==
NULL) {
137 const U32 loopLimit = std::numeric_limits<U32>::max();
140 while(arrayIdx < maxNum && limitCount < loopLimit) {
144 if((direntData = ::readdir(dirPtr)) !=
NULL) {
146 if(direntData->d_type == DT_REG) {
153 fileArray[arrayIdx++] = str;
166 if(limitCount == loopLimit) {
170 if(::closedir(dirPtr) == -1) {
184 if(::unlink(path) == -1) {
218 if(::rename(originPath, destPath) == -1) {
275 return fileSystemStatus;
286 struct stat* fileInfo=
NULL) {
288 struct stat local_info;
291 fileInfo = &local_info;
294 if(::stat(filePath, fileInfo) == -1) {
315 if(!S_ISREG(fileInfo->st_mode)) {
343 while(loopCounter < copyLoopLimit) {
345 file_status = source.
read(&fileBuffer, chunkSize,
false);
355 file_status = destination.
write(fileBuffer, chunkSize,
true);
396 fs_status =
copyFileData(source, destination, fileSize);
398 (void) source.
close();
399 (void) destination.
close();
429 if(!createMissingDest) {
441 fs_status =
copyFileData(source, destination, fileSize);
443 (void) source.
close();
444 (void) destination.
close();
452 struct stat fileStatStruct;
457 size = fileStatStruct.st_size;
467 if (::chdir(path) == -1) {
496 struct statvfs fsStat;
497 int ret = statvfs(path, &fsStat);
518 totalBytes = (
U64) fsStat.f_blocks * (
U64) fsStat.f_frsize;
519 freeBytes = (
U64) fsStat.f_bfree * (
U64) fsStat.f_frsize;
527 struct dirent *direntData =
NULL;
529 const U64 loopLimit = ((((
U64) 1) << 32)-1);
532 if((dirPtr = ::opendir(directory)) ==
NULL) {
552 for(limitCount = 0; limitCount < loopLimit; limitCount++) {
553 if((direntData = ::readdir(dirPtr)) !=
NULL) {
555 if(direntData->d_type == DT_REG) {
568 if(limitCount == loopLimit) {
572 if(::closedir(dirPtr) == -1) {
Status getFileCount(const char *directory, U32 &fileCount)
counts the number of files in the given directory
@ NO_PERMISSION
No permission to read/write file.
Status initAndCheckFileStats(const char *filePath, struct stat *fileInfo=NULL)
void close(void)
close file
Status copyFile(const char *originPath, const char *destPath)
moves a file from origin to destination
Status read(void *buffer, NATIVE_INT_TYPE &size, bool waitForFull=true)
waitForFull = true to wait for all bytes to be read
uint8_t U8
8-bit unsigned integer
Status readDirectory(const char *path, const U32 maxNum, Fw::EightyCharString fileArray[])
Status removeDirectory(const char *path)
remove a directory at location path
Status copyFileData(File source, File destination, U64 size)
Status changeWorkingDirectory(const char *path)
move current directory to path
@ NOT_DIR
Path is not a directory.
@ OTHER_ERROR
other OS-specific error
Status moveFile(const char *originPath, const char *destPath)
@ NOT_EMPTY
directory is not empty
Status write(const void *buffer, NATIVE_INT_TYPE &size, bool waitForDone=true)
write size; will return amount written or errno
@ DOESNT_EXIST
File doesn't exist (for read)
@ OP_OK
Operation was successful.
@ INVALID_PATH
Path is too long, too many sym links, doesn't exist, ect.
@ IS_DIR
Path is a directory.
@ OPEN_WRITE
Open file for writing.
@ OPEN_APPEND
Open file for appending.
Status open(const char *fileName, Mode mode)
open file. Writing creates file if it doesn't exist
Status appendFile(const char *originPath, const char *destPath, bool createMissingDest=false)
copies a file from origin to destination
@ ALREADY_EXISTS
File already exists.
Status getFreeSpace(const char *path, U64 &totalBytes, U64 &freeBytes)
get FS free and total space in bytes on filesystem containing path
@ FILE_LIMIT
Too many files or links.
Status handleFileError(File::Status fileStatus)
Status createDirectory(const char *path)
create a new directory at location path
@ NO_PERMISSION
No permission to write.
Declares ISF basic types.
@ OP_OK
Operation was successful.
Status getFileSize(const char *path, U64 &size)
append file origin to destination file. If boolean true, creates a brand new file if the destination ...
int NATIVE_INT_TYPE
native integer type declaration
@ OPEN_READ
Open file for reading.
@ BUSY
Operand is in use by the system or by a process.
Status removeFile(const char *path)
removes a file at location path
#define FILE_SYSTEM_CHUNK_SIZE