F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Os::DirectoryInterface Class Referenceabstract

#include <Os/Directory.hpp>

Inheritance diagram for Os::DirectoryInterface:
Os::Directory Os::Posix::Directory::PosixDirectory Os::Stub::Directory::StubDirectory

Public Types

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 }
 

Public Member Functions

 DirectoryInterface ()=default
 default constructor More...
 
virtual ~DirectoryInterface ()=default
 default virtual destructor More...
 
 DirectoryInterface (const DirectoryInterface &other)=delete
 copy constructor is forbidden More...
 
DirectoryInterfaceoperator= (const DirectoryInterface &other)=delete
 assignment operator is forbidden More...
 
virtual DirectoryHandlegetHandle ()=0
 return the underlying Directory handle (implementation specific) More...
 
virtual Status open (const char *path, OpenMode mode)=0
 Open or create a directory. More...
 
virtual Status rewind ()=0
 Rewind directory stream. More...
 
virtual Status read (char *fileNameBuffer, FwSizeType buffSize)=0
 Get next filename from directory stream. More...
 
virtual void close ()=0
 Get next filename from directory stream and write it to a Fw::StringBase object. More...
 

Static Public Member Functions

static DirectoryInterfacegetDelegate (DirectoryHandleStorage &aligned_new_memory)
 provide a pointer to a Directory delegate object More...
 

Detailed Description

Definition at line 17 of file Directory.hpp.

Member Enumeration Documentation

◆ OpenMode

Enumerator
READ 

Error if directory doesn't exist.

CREATE_IF_MISSING 

Create directory if it doesn't exist.

CREATE_EXCLUSIVE 

Create directory and error if it already exists.

MAX_OPEN_MODE 

Maximum value of OpenMode.

Definition at line 33 of file Directory.hpp.

◆ Status

Enumerator
OP_OK 

Operation was successful.

DOESNT_EXIST 

Directory doesn't exist.

NO_PERMISSION 

No permission to read directory.

NOT_OPENED 

Directory hasn't been opened yet.

NOT_DIR 

Path is not a directory.

NO_MORE_FILES 

Directory stream has no more files.

FILE_LIMIT 

Directory has more files than can be read.

BAD_DESCRIPTOR 

Directory stream descriptor is invalid.

ALREADY_EXISTS 

Directory already exists.

NOT_SUPPORTED 

Operation is not supported by the current implementation.

OTHER_ERROR 

A catch-all for other errors. Have to look in implementation-specific code.

Definition at line 19 of file Directory.hpp.

Constructor & Destructor Documentation

◆ DirectoryInterface() [1/2]

Os::DirectoryInterface::DirectoryInterface ( )
default

default constructor

◆ ~DirectoryInterface()

virtual Os::DirectoryInterface::~DirectoryInterface ( )
virtualdefault

default virtual destructor

◆ DirectoryInterface() [2/2]

Os::DirectoryInterface::DirectoryInterface ( const DirectoryInterface other)
delete

copy constructor is forbidden

Member Function Documentation

◆ close()

virtual void Os::DirectoryInterface::close ( )
pure virtual

Get next filename from directory stream and write it to a Fw::StringBase object.

Parameters
filenameFw::StringBase (or derived) object to store filename in
Returns
status of the operation

Close directory

Implemented in Os::Stub::Directory::StubDirectory, Os::Posix::Directory::PosixDirectory, and Os::Directory.

◆ getDelegate()

DirectoryInterface * Os::DirectoryInterface::getDelegate ( DirectoryHandleStorage aligned_placement_new_memory)
static

provide a pointer to a Directory delegate object

get a delegate for DirectoryInterface that intercepts calls for stub Directory usage

Parameters
aligned_new_memoryaligned memory to fill
Returns
: pointer to delegate

Definition at line 20 of file DefaultFile.cpp.

◆ getHandle()

virtual DirectoryHandle* Os::DirectoryInterface::getHandle ( )
pure virtual

return the underlying Directory handle (implementation specific)

Returns
internal Directory handle representation

Implemented in Os::Stub::Directory::StubDirectory, Os::Posix::Directory::PosixDirectory, and Os::Directory.

◆ open()

virtual Status Os::DirectoryInterface::open ( const char *  path,
OpenMode  mode 
)
pure virtual

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.

Parameters
pathpath of directory to open
modeenum (READ, CREATE_IF_MISSING, CREATE_EXCLUSIVE). See notes above for more information
Returns
status of the operation

Implemented in Os::Stub::Directory::StubDirectory, Os::Posix::Directory::PosixDirectory, and Os::Directory.

◆ operator=()

DirectoryInterface& Os::DirectoryInterface::operator= ( const DirectoryInterface other)
delete

assignment operator is forbidden

◆ read()

virtual Status Os::DirectoryInterface::read ( char *  fileNameBuffer,
FwSizeType  buffSize 
)
pure virtual

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.

Parameters
fileNameBufferbuffer to store filename
buffSizesize of fileNameBuffer
Returns
status of the operation

Implemented in Os::Stub::Directory::StubDirectory, Os::Posix::Directory::PosixDirectory, and Os::Directory.

◆ rewind()

virtual Status Os::DirectoryInterface::rewind ( )
pure virtual

Rewind directory stream.

Each read operation moves the seek position forward. This function resets the seek position to the beginning.

Returns
status of the operation

Implemented in Os::Stub::Directory::StubDirectory, Os::Posix::Directory::PosixDirectory, and Os::Directory.


The documentation for this class was generated from the following files: