GCC Code Coverage Report


Directory: ./
File: Os/Stub/Directory.hpp
Date: 2026-09-03 21:13:48
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 2 2 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // ======================================================================
2 // \title Os/Stub/Directory.hpp
3 // \brief stub definitions for Os::Directory
4 // ======================================================================
5 #ifndef OS_STUB_DIRECTORY_HPP
6 #define OS_STUB_DIRECTORY_HPP
7
8 #include "Os/Directory.hpp"
9 namespace Os {
10 namespace Stub {
11 namespace Directory {
12
13 struct StubDirectoryHandle : public DirectoryHandle {};
14
15 //! \brief stub implementation of Os::Directory
16 //!
17 //! Stub implementation of `DirectoryInterface` for use as a delegate class handling error-only file operations.
18 //!
19 class StubDirectory : public DirectoryInterface {
20 public:
21 //! \brief constructor
22 1 StubDirectory() = default;
23
24 //! \brief destructor
25 2 ~StubDirectory() override = default;
26
27 //! \brief return the underlying Directory handle (implementation specific)
28 //! \return internal Directory handle representation
29 DirectoryHandle* getHandle() override;
30
31 // ------------------------------------------------------------
32 // Implementation-specific Directory member functions
33 // ------------------------------------------------------------
34
35 //! \brief Open or create a directory
36 //!
37 //! Using the path provided, this function will open or create a directory.
38 //! Use OpenMode::READ to open an existing directory and error if the directory is not found
39 //! Use OpenMode::CREATE_IF_MISSING to open a directory, creating the directory if it doesn't exist
40 //! Use OpenMode::CREATE_EXCLUSIVE to open a directory, creating the directory and erroring if it already exists
41 //!
42 //! It is invalid to pass `nullptr` as the path.
43 //! It is invalid to supply `mode` as a non-enumerated value.
44 //!
45 //! \param path: path of directory to open
46 //! \param mode: enum (READ, CREATE_IF_MISSING, CREATE_EXCLUSIVE). See notes above for more information
47 //! \return status of the operation
48 Status open(const char* path, OpenMode mode) override;
49
50 //! \brief Check if Directory is open or not
51 //! \return true if Directory is open, false otherwise
52 bool isOpen();
53
54 //! \brief Rewind directory stream
55 //!
56 //! Each read operation moves the seek position forward. This function resets the seek position to the beginning.
57 //!
58 //! \return status of the operation
59 Status rewind() override;
60
61 //! \brief Get next filename from directory stream
62 //!
63 //! Writes at most buffSize characters of the file name to fileNameBuffer.
64 //! This function skips the current directory (.) and parent directory (..) entries.
65 //! Returns NO_MORE_FILES if there are no more files to read from the buffer.
66 //!
67 //! It is invalid to pass `nullptr` as fileNameBuffer.
68 //!
69 //! \param fileNameBuffer: buffer to store filename
70 //! \param buffSize: size of fileNameBuffer
71 //! \return status of the operation
72 Status read(char* fileNameBuffer, FwSizeType buffSize) override;
73
74 //! \brief Close directory
75 void close() override;
76
77 private:
78 //! Handle for StubDirectory
79 StubDirectoryHandle m_handle;
80 };
81
82 } // namespace Directory
83 } // namespace Stub
84 } // namespace Os
85 #endif // OS_STUB_DIRECTORY_HPP
86