GCC Code Coverage Report


Directory: ./
File: Os/Stub/FileSystem.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/FileSystem.hpp
3 // \brief stub fileSystem definitions for Os::FileSystem
4 // ======================================================================
5 #ifndef OS_STUB_FILESYSTEM_HPP
6 #define OS_STUB_FILESYSTEM_HPP
7
8 #include "Os/FileSystem.hpp"
9
10 namespace Os {
11 namespace Stub {
12 namespace FileSystem {
13
14 struct StubFileSystemHandle : public FileSystemHandle {};
15
16 //! \brief stub implementation of Os::FileSystem
17 //!
18 //! Stub implementation of `FileSystemInterface` for use as a delegate class handling error-only fileSystem operations.
19 //!
20 class StubFileSystem : public FileSystemInterface {
21 public:
22 //! \brief constructor
23 1 StubFileSystem() = default;
24
25 //! \brief destructor
26 2 ~StubFileSystem() override = default;
27
28 // ------------------------------------------------------------
29 // Implementation-specific FileSystem member functions
30 // ------------------------------------------------------------
31
32 //! \brief Remove a directory at the specified path
33 //!
34 //! It is invalid to pass `nullptr` as the path.
35 //!
36 //! \param path The path of the directory to remove
37 //! \return Status of the operation
38 Status _removeDirectory(const char* path) override;
39
40 //! \brief Remove a file at the specified path
41 //!
42 //! It is invalid to pass `nullptr` as the path.
43 //!
44 //! \param path The path of the file to remove
45 //! \return Status of the operation
46 Status _removeFile(const char* path) override;
47
48 //! \brief Rename a file from source to destination
49 //!
50 //! If the rename fails due to a cross-device operation, this function should return EXDEV_ERROR
51 //! and moveFile can be used instead to force a copy-and-remove.
52 //!
53 //! It is invalid to pass `nullptr` as sourcePath or destPath.
54 //!
55 //! \param sourcePath The path of the source file
56 //! \param destPath The path of the destination file
57 //! \return Status of the operation
58 Status _rename(const char* sourcePath, const char* destPath) override;
59
60 //! \brief Get filesystem free and total space in bytes on the filesystem containing the specified path
61 //!
62 //! It is invalid to pass `nullptr` as the path.
63 //!
64 //! \param path The path on the filesystem to query
65 //! \param totalBytes Reference to store the total bytes on the filesystem
66 //! \param freeBytes Reference to store the free bytes on the filesystem
67 //! \return Status of the operation
68 Status _getFreeSpace(const char* path, FwSizeType& totalBytes, FwSizeType& freeBytes) override;
69
70 //! \brief Get the current working directory
71 //!
72 //! Writes the current working directory path to the provided buffer of size bufferSize.
73 //! If the buffer is too small to hold the full path, the function will return BUFFER_TOO_SMALL.
74 //!
75 //! It is invalid to pass `nullptr` as the path.
76 //! It is invalid to pass a bufferSize of 0.
77 //!
78 //! \param path Buffer to store the current working directory path
79 //! \param bufferSize Size of the buffer
80 //! \return Status of the operation
81 Status _getWorkingDirectory(char* path, FwSizeType bufferSize) override;
82
83 //! \brief Change the current working directory to the specified path
84 //!
85 //! It is invalid to pass `nullptr` as the path.
86 //!
87 //! \param path The path of the new working directory
88 //! \return Status of the operation
89 Status _changeWorkingDirectory(const char* path) override;
90
91 //! \brief returns the raw fileSystem handle
92 //!
93 //! Gets the raw fileSystem handle from the implementation. Note: users must include the implementation specific
94 //! header to make any real use of this handle. Otherwise it//!must* be passed as an opaque type.
95 //!
96 //! \return raw fileSystem handle
97 //!
98 FileSystemHandle* getHandle() override;
99
100 //! \brief Get the type of the path (file, directory, etc.)
101 //!
102 //! It is invalid to pass `nullptr` as the path.
103 //!
104 //! \param path The path to check
105 //! \param pathType Reference to store the path type
106 //! \return Status of the operation
107 Status _getPathType(const char* path, PathType& pathType) override;
108
109 private:
110 //! FileSystem handle for PosixFileSystem
111 StubFileSystemHandle m_handle;
112 };
113
114 } // namespace FileSystem
115 } // namespace Stub
116 } // namespace Os
117 #endif // OS_STUB_FILESYSTEM_HPP
118