* @brief This class provides an interface for file operations. */
| 8 | * @brief This class provides an interface for file operations. |
| 9 | */ |
| 10 | class KittyIOFile |
| 11 | { |
| 12 | private: |
| 13 | int _fd; |
| 14 | std::string _filePath; |
| 15 | int _flags; |
| 16 | mode_t _mode; |
| 17 | int _error; |
| 18 | size_t _bufferSize; |
| 19 | |
| 20 | public: |
| 21 | KittyIOFile() : _fd(-1), _flags(0), _mode(0), _error(0), _bufferSize(KT_IO_BUFFER_SIZE) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @brief Constructs a new KittyIOFile object with file path, flags, and mode. |
| 27 | * |
| 28 | * @param filePath The path to the file. |
| 29 | * @param flags The flags for opening the file. |
| 30 | * @param mode The mode for opening the file. |
| 31 | */ |
| 32 | KittyIOFile(const std::string &filePath, int flags, mode_t mode) |
| 33 | : _fd(-1), _filePath(filePath), _flags(flags), _mode(mode), _error(0), _bufferSize(KT_IO_BUFFER_SIZE) |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @brief Constructs a new KittyIOFile object with file path and flags. |
| 39 | * |
| 40 | * @param filePath The path to the file. |
| 41 | * @param flags The flags for opening the file. |
| 42 | */ |
| 43 | KittyIOFile(const std::string &filePath, int flags) |
| 44 | : _fd(-1), _filePath(filePath), _flags(flags), _mode(0), _error(0), _bufferSize(KT_IO_BUFFER_SIZE) |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | ~KittyIOFile() |
| 49 | { |
| 50 | if (_fd >= 0) |
| 51 | { |
| 52 | ::close(_fd); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @brief Opens the file. |
| 58 | * |
| 59 | * @return true if the file was opened successfully, false otherwise. |
| 60 | */ |
| 61 | bool open(); |
| 62 | |
| 63 | /** |
| 64 | * @brief Closes the file. |
| 65 | * |
| 66 | * @return true if the file was closed successfully, false otherwise. |
| 67 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected