11#include "plugify/types.hpp"
18 std::filesystem::path path;
20 std::filesystem::file_time_type last_write_time;
21 std::filesystem::file_type type;
22 std::filesystem::perms permissions;
24 bool is_directory()
const {
25 return type == std::filesystem::file_type::directory;
28 bool is_regular_file()
const {
29 return type == std::filesystem::file_type::regular;
32 bool is_symlink()
const {
33 return type == std::filesystem::file_type::symlink;
41 bool recursive =
false;
42 bool follow_symlinks =
false;
43 bool skip_permission_denied =
true;
44 std::optional<std::regex> filter_pattern;
45 std::function<bool(
const FileInfo&)> filter_predicate;
70 WriteTextFile(
const std::filesystem::path& path, std::string_view content) = 0;
76 WriteBinaryFile(
const std::filesystem::path& path, std::span<const uint8_t> data) = 0;
82 virtual bool IsExists(
const std::filesystem::path& path) = 0;
87 virtual bool IsDirectory(
const std::filesystem::path& path) = 0;
109 const std::filesystem::path& directory,
117 const std::filesystem::path& directory,
118 std::span<const std::string_view> patterns,
119 bool recursive =
true
142 Copy(
const std::filesystem::path& from,
const std::filesystem::path& to) = 0;
148 Move(
const std::filesystem::path& from,
const std::filesystem::path& to) = 0;
164 GetRelativePath(
const std::filesystem::path& path,
const std::filesystem::path& base) = 0;
Simple filesystem interface for reading files and iterating directories.
virtual bool IsDirectory(const std::filesystem::path &path)=0
Check if path is a directory.
virtual Result< std::vector< std::filesystem::path > > FindFiles(const std::filesystem::path &directory, std::span< const std::string_view > patterns, bool recursive=true)=0
Find files matching pattern.
virtual Result< void > WriteTextFile(const std::filesystem::path &path, std::string_view content)=0
Write text to file.
virtual Result< void > Remove(const std::filesystem::path &path)=0
Remove file or empty directory.
virtual bool IsRegularFile(const std::filesystem::path &path)=0
Check if path is a regular file.
virtual Result< void > WriteBinaryFile(const std::filesystem::path &path, std::span< const uint8_t > data)=0
Write binary data to file.
virtual Result< FileInfo > GetFileInfo(const std::filesystem::path &path)=0
Get file information.
virtual Result< std::string > ReadTextFile(const std::filesystem::path &path)=0
Read entire file as text.
virtual Result< std::vector< FileInfo > > ListDirectory(const std::filesystem::path &directory)=0
List files in directory (non-recursive)
virtual Result< std::vector< FileInfo > > IterateDirectory(const std::filesystem::path &directory, const DirectoryIterationOptions &options={})=0
Iterate over files in directory with options.
virtual Result< void > Move(const std::filesystem::path &from, const std::filesystem::path &to)=0
Move/rename file or directory.
virtual Result< std::vector< uint8_t > > ReadBinaryFile(const std::filesystem::path &path)=0
Read entire file as binary.
virtual bool IsExists(const std::filesystem::path &path)=0
Check if path exists.
virtual Result< void > CreateDirectories(const std::filesystem::path &path)=0
Create directory (including parents)
virtual Result< void > RemoveAll(const std::filesystem::path &path)=0
Remove directory and all contents.
virtual Result< void > Copy(const std::filesystem::path &from, const std::filesystem::path &to)=0
Copy file or directory.
Directory iteration options.