11 : m_is_open(false), m_handle_storage(), m_delegate(*
DirectoryInterface::getDelegate(m_handle_storage)) {
12 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
16 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
17 if (this->m_is_open) {
27 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
32 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
34 FW_ASSERT(mode >= 0 and mode < OpenMode::MAX_OPEN_MODE);
35 Status status = this->m_delegate.
open(path, mode);
37 this->m_is_open =
true;
43 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
44 return this->m_is_open;
47 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
48 if (not this->m_is_open) {
49 return Status::NOT_OPENED;
51 return this->m_delegate.
rewind();
55 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
56 if (not this->m_is_open) {
57 return Status::NOT_OPENED;
60 Status status = this->m_delegate.
read(fileNameBuffer, bufSize);
61 fileNameBuffer[bufSize - 1] =
'\0';
66 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
67 if (not this->m_is_open) {
68 return Status::NOT_OPENED;
74 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
75 this->m_is_open =
false;
76 return this->m_delegate.
close();
84 if (not this->m_is_open) {
85 return Status::NOT_OPENED;
91 const FwSizeType loopLimit = std::numeric_limits<FwSizeType>::max();
97 for (
FwSizeType iter = 0; iter < loopLimit; ++iter) {
98 readStatus = this->
read(unusedBuffer,
sizeof(unusedBuffer));
99 if (readStatus == Status::NO_MORE_FILES) {
118 if (not this->m_is_open) {
119 return Status::NOT_OPENED;
131 for (index = 0; index < filenameArraySize; index++) {
132 readStatus = this->
read(filenameArray[index]);
133 if (readStatus == Status::NO_MORE_FILES) {
139 filenameCount = index;
Status readDirectory(Fw::String filenameArray[], const FwSizeType arraySize, FwSizeType &filenameCount)
Read the contents of the directory and store filenames in filenameArray of size arraySize.
virtual DirectoryHandle * getHandle()=0
return the underlying Directory handle (implementation specific)
virtual ~DirectoryInterface()=default
default virtual destructor
virtual Status read(char *fileNameBuffer, FwSizeType buffSize)=0
Get next filename from directory stream.
A catch-all for other errors. Have to look in implementation-specific code.
PlatformSizeType FwSizeType
Status rewind() override
Rewind directory stream.
Status getFileCount(FwSizeType &fileCount)
Get the number of files in the directory.
void close() override
Close directory.
Status read(char *fileNameBuffer, FwSizeType buffSize) override
Get next filename from directory stream.
bool isOpen()
Check if Directory is open or not.
Status open(const char *path, OpenMode mode) override
Open or create a directory.
virtual Status open(const char *path, OpenMode mode)=0
Open or create a directory.
DirectoryHandle * getHandle() override
return the underlying Directory handle (implementation specific)
virtual Status rewind()=0
Rewind directory stream.
virtual SizeType getCapacity() const =0
return size of buffer
~Directory() final
Destructor.
virtual void close()=0
Get next filename from directory stream and write it to a Fw::StringBase object.
virtual const CHAR * toChar() const =0