![]() |
F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
|
Directory class. More...
#include <Os/Directory.hpp>
Public Member Functions | |
| DirectoryCommon () | |
| Constructor. More... | |
| ~DirectoryCommon () | |
| Destructor. More... | |
| DirectoryHandle * | getHandle () |
| return the underlying Directory handle (implementation specific) More... | |
| Status | open (const char *path, OpenMode mode) |
| Open or create a directory. More... | |
| bool | isOpen () |
| Check if Directory is open or not. More... | |
| Status | rewind () |
| Rewind directory stream. More... | |
| Status | read (char *fileNameBuffer, FwSizeType buffSize) |
| Get next filename from directory stream. More... | |
| void | close () |
| Close directory. More... | |
| Status | read (Fw::StringBase &filename) |
| Get next filename from directory stream and write it to a Fw::StringBase object. More... | |
| Status | readDirectory (Fw::ExternalArray< Fw::String > &filenameArray, FwSizeType &filenameCount) |
| Read the contents of the directory and store filenames in the supplied array. More... | |
| DEPRECATED (Status readDirectory(Fw::String filenameArray[], const FwSizeType arraySize, FwSizeType &filenameCount), "Use readDirectory(Fw::ExternalArray<Fw::String>& filenameArray, FwSizeType& filenameCount) instead") | |
| Read the contents of the directory and store filenames in filenameArray of size arraySize. More... | |
| Status | getFileCount (FwSizeType &fileCount) |
| Get the number of files in the directory. More... | |
Additional Inherited Members | |
Public Types inherited from Os::DirectoryUserInterface | |
| enum | Status { OP_OK, DOESNT_EXIST, NO_PERMISSION, NOT_OPENED, NOT_DIR, NO_MORE_FILES, FILE_LIMIT, BAD_DESCRIPTOR, ALREADY_EXISTS, NOT_SUPPORTED, OTHER_ERROR } |
| enum | OpenMode { READ, CREATE_IF_MISSING, CREATE_EXCLUSIVE, MAX_OPEN_MODE } |
Directory class.
This class provides a common interface for directory operations, such as reading files in a directory and getting the number of files in a directory.
Definition at line 24 of file Directory.hpp.
| Os::DirectoryCommon< T >::DirectoryCommon | ( | ) |
Constructor.
Definition at line 160 of file Directory.hpp.
| Os::DirectoryCommon< T >::~DirectoryCommon | ( | ) |
Destructor.
Destructor will close the Directory if it is open
Definition at line 163 of file Directory.hpp.
| void Os::DirectoryCommon< T >::close | ( | ) |
Close directory.
Definition at line 221 of file Directory.hpp.
| Os::DirectoryCommon< T >::DEPRECATED | ( | Status | readDirectoryFw::String filenameArray[], const FwSizeType arraySize, FwSizeType &filenameCount, |
| "Use readDirectory(Fw::ExternalArray<Fw::String>& filenameArray, FwSizeType& filenameCount) instead" | |||
| ) |
Read the contents of the directory and store filenames in filenameArray of size arraySize.
The function first rewinds the directory stream to ensure reading starts from the beginning. After reading, it rewinds the directory stream again, resetting seek position to beginning.
| filenameArray | array to store filenames |
| arraySize | size of filenameArray |
| filenameCount | number of filenames written to filenameArray (output) |
| DirectoryCommon< T >::Status Os::DirectoryCommon< T >::getFileCount | ( | FwSizeType & | fileCount | ) |
Get the number of files in the directory.
Counts the number of files in the directory by reading each file entry and writing the count to fileCount.
The function first rewinds the directory stream to ensure counting starts from the beginning. After counting, it rewinds the directory stream again, resetting seek position to beginning.
| fileCount | Reference to a variable where the file count will be stored. |
Definition at line 231 of file Directory.hpp.
| DirectoryHandle * Os::DirectoryCommon< T >::getHandle | ( | ) |
return the underlying Directory handle (implementation specific)
Definition at line 173 of file Directory.hpp.
| bool Os::DirectoryCommon< T >::isOpen | ( | ) |
Check if Directory is open or not.
Definition at line 189 of file Directory.hpp.
| DirectoryCommon< T >::Status Os::DirectoryCommon< T >::open | ( | const char * | path, |
| OpenMode | mode | ||
| ) |
Open or create a directory.
Using the path provided, this function will open or create a directory. Use OpenMode::READ to open an existing directory and error if the directory is not found Use OpenMode::CREATE_IF_MISSING to open a directory, creating the directory if it doesn't exist Use OpenMode::CREATE_EXCLUSIVE to open a directory, creating the directory and erroring if it already exists
It is invalid to pass nullptr as the path. It is invalid to supply mode as a non-enumerated value.
| path | path of directory to open |
| mode | enum (READ, CREATE_IF_MISSING, CREATE_EXCLUSIVE). See notes above for more information |
Definition at line 178 of file Directory.hpp.
| DirectoryCommon< T >::Status Os::DirectoryCommon< T >::read | ( | char * | fileNameBuffer, |
| FwSizeType | buffSize | ||
| ) |
Get next filename from directory stream.
Write at most buffSize characters of the file name to fileNameBuffer and guarantee null-termination. This function skips the current directory (.) and parent directory (..) entries. Returns NO_MORE_FILES if there are no more files to read from the buffer.
It is invalid to pass nullptr as fileNameBuffer.
| fileNameBuffer | buffer to store filename |
| buffSize | size of fileNameBuffer |
Definition at line 201 of file Directory.hpp.
| DirectoryCommon< T >::Status Os::DirectoryCommon< T >::read | ( | Fw::StringBase & | filename | ) |
Get next filename from directory stream and write it to a Fw::StringBase object.
| filename | Fw::StringBase (or derived) object to store filename in |
Definition at line 213 of file Directory.hpp.
| DirectoryCommon< T >::Status Os::DirectoryCommon< T >::readDirectory | ( | Fw::ExternalArray< Fw::String > & | filenameArray, |
| FwSizeType & | filenameCount | ||
| ) |
Read the contents of the directory and store filenames in the supplied array.
Reads at most filenameArray.getSize() filenames. The function first rewinds the directory stream to ensure reading starts from the beginning. After reading, it rewinds the directory stream again, resetting seek position to beginning.
| filenameArray | array to store filenames |
| filenameCount | number of filenames written to filenameArray (output) |
Definition at line 262 of file Directory.hpp.
| DirectoryCommon< T >::Status Os::DirectoryCommon< T >::rewind | ( | ) |
Rewind directory stream.
Each read operation moves the seek position forward. This function resets the seek position to the beginning.
Definition at line 193 of file Directory.hpp.