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;
61 Status status = this->m_delegate.
read(fileNameBuffer, bufSize);
62 fileNameBuffer[bufSize - 1] =
'\0';
67 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
68 if (not this->m_is_open) {
69 return Status::NOT_OPENED;
75 FW_ASSERT(&this->m_delegate == reinterpret_cast<DirectoryInterface*>(&this->m_handle_storage[0]));
76 this->m_is_open =
false;
77 return this->m_delegate.
close();
85 if (not this->m_is_open) {
86 return Status::NOT_OPENED;
92 const FwSizeType loopLimit = std::numeric_limits<FwSizeType>::max();
98 for (
FwSizeType iter = 0; iter < loopLimit; ++iter) {
99 readStatus = this->
read(unusedBuffer,
sizeof(unusedBuffer));
100 if (readStatus == Status::NO_MORE_FILES) {
117 if (not this->m_is_open) {
118 return Status::NOT_OPENED;
130 for (index = 0; index < filenameArray.
getSize(); index++) {
131 readStatus = this->
read(filenameArray[index]);
132 if (readStatus == Status::NO_MORE_FILES) {
138 filenameCount = index;
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
virtual const CHAR * toChar() const =0
Convert to a C-style char*.
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.
virtual SizeType getCapacity() const =0
Return the size of the buffer.
FwSizeType getSize() const
Status readDirectory(Fw::ExternalArray< Fw::String > &filenameArray, FwSizeType &filenameCount)
Read the contents of the directory and store filenames in the supplied array.
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.
~Directory() final
Destructor.
virtual void close()=0
Get next filename from directory stream and write it to a Fw::StringBase object.