DotNameLib
Loading...
Searching...
No Matches
IFileWriter.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <cstdint>
5#include <filesystem>
6#include <string>
7#include <vector>
8
9namespace dotnamecpp::utils {
10
18 public:
19 virtual ~IFileWriter() = default;
20
29 [[nodiscard]]
30 virtual Result<void, FileError> write(const std::filesystem::path &filePath,
31 const std::string &content,
32 bool append = false) const = 0;
33
42 [[nodiscard]]
43 virtual Result<void, FileError> writeBytes(const std::filesystem::path &filePath,
44 const std::vector<uint8_t> &data,
45 bool append = false) const = 0;
46
55 [[nodiscard]]
56 virtual Result<void, FileError> writeLines(const std::filesystem::path &filePath,
57 const std::vector<std::string> &lines,
58 bool append = false) const = 0;
59
66 [[nodiscard]]
67 virtual Result<void, FileError> touch(const std::filesystem::path &filePath) const = 0;
68 };
69
70} // namespace dotnamecpp::utils
Interface for writing file content.
Definition IFileWriter.hpp:17
virtual Result< void, FileError > writeLines(const std::filesystem::path &filePath, const std::vector< std::string > &lines, bool append=false) const =0
Write lines to file (each string becomes one line)
virtual Result< void, FileError > writeBytes(const std::filesystem::path &filePath, const std::vector< uint8_t > &data, bool append=false) const =0
Write binary data to file.
virtual ~IFileWriter()=default
virtual Result< void, FileError > write(const std::filesystem::path &filePath, const std::string &content, bool append=false) const =0
Write string content to file.
virtual Result< void, FileError > touch(const std::filesystem::path &filePath) const =0
Create empty file or update timestamp of existing file.
Definition UtilsError.hpp:93
Definition DirectoryManager.cpp:5