GCC Code Coverage Report


Directory: ./
File: Posix/FileSystem.hpp
Date: 2026-09-03 22:13:09
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 2 2 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // ======================================================================
2 // \title Os/Posix/FileSystem.hpp
3 // \brief Posix FileSystem definitions for Os::FileSystem
4 // ======================================================================
5 #ifndef OS_POSIX_FILESYSTEM_HPP
6 #define OS_POSIX_FILESYSTEM_HPP
7
8 #include "Os/FileSystem.hpp"
9
10 namespace Os {
11 namespace Posix {
12 namespace FileSystem {
13
14 struct PosixFileSystemHandle : public FileSystemHandle {};
15
16 //! \brief Posix implementation of Os::FileSystem
17 //!
18 //! Posix implementation of `FileSystemInterface` for use as a delegate class handling error-only fileSystem operations.
19 //!
20 class PosixFileSystem : public FileSystemInterface {
21 public:
22 //! \brief constructor
23 1 PosixFileSystem() = default;
24
25 //! \brief destructor
26 2 ~PosixFileSystem() override = default;
27
28 // ------------------------------------------------------------
29 // Implementation-specific member functions - overrides
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 Get 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 FileSystemHandle* getHandle() override;
98
99 //! \brief Get the type of the path (file, directory, etc.)
100 //!
101 //! It is invalid to pass `nullptr` as the path.
102 //!
103 //! \param path The path to check
104 //! \return PathType of the path
105 Status _getPathType(const char* path, PathType& pathType) override;
106
107 private:
108 //! FileSystem handle for PosixFileSystem
109 PosixFileSystemHandle m_handle;
110 }; // class PosixFileSystem
111
112 } // namespace FileSystem
113 } // namespace Posix
114 } // namespace Os
115 #endif // OS_POSIX_FILESYSTEM_HPP
116