DotNameLib
Loading...
Searching...
No Matches
FileReader.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace dotnamecpp::utils {
6
7 class FileReader final : public IFileReader {
8 public:
9 FileReader() = default;
10 FileReader(const FileReader &) = delete;
11 FileReader &operator=(const FileReader &) = delete;
12 FileReader(FileReader &&) = delete;
14 ~FileReader() override = default;
15
16 [[nodiscard]]
17 Result<std::string, FileError> read(const std::filesystem::path &filePath) const override;
18
19 [[nodiscard]]
21 readBytes(const std::filesystem::path &filePath) const override;
22
23 [[nodiscard]]
25 readLines(const std::filesystem::path &filePath) const override;
26
27 [[nodiscard]]
28 bool exists(const std::filesystem::path &filePath) const override;
29
30 [[nodiscard]]
31 Result<std::uintmax_t, FileError> getSize(const std::filesystem::path &filePath) const override;
32
33 private:
34 [[nodiscard]]
35 static std::optional<FileError> validatePath(const std::filesystem::path &filePath);
36 };
37
38} // namespace dotnamecpp::utils
FileReader(FileReader &&)=delete
FileReader & operator=(FileReader &&)=delete
bool exists(const std::filesystem::path &filePath) const override
Check if a file exists.
Definition FileReader.cpp:107
FileReader & operator=(const FileReader &)=delete
Result< std::string, FileError > read(const std::filesystem::path &filePath) const override
Read the entire content of a file as a string.
Definition FileReader.cpp:9
Result< std::vector< std::string >, FileError > readLines(const std::filesystem::path &filePath) const override
Read the content of a file as a vector of lines.
Definition FileReader.cpp:75
FileReader(const FileReader &)=delete
Result< std::vector< uint8_t >, FileError > readBytes(const std::filesystem::path &filePath) const override
Read the entire content of a file as a vector of bytes.
Definition FileReader.cpp:38
Result< std::uintmax_t, FileError > getSize(const std::filesystem::path &filePath) const override
Get the Size object.
Definition FileReader.cpp:113
~FileReader() override=default
Interface for reading file content.
Definition IFileReader.hpp:17
Definition UtilsError.hpp:93
Definition DirectoryManager.cpp:5
Definition UtilsError.hpp:35