2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 07:33:10 +08:00
|
|
|
#include "vcpkg_expected.h"
|
2016-11-30 10:08:53 +08:00
|
|
|
#include "filesystem_fs.h"
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-01-06 04:47:08 +08:00
|
|
|
namespace vcpkg::Files
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-09 07:26:26 +08:00
|
|
|
__interface Filesystem
|
|
|
|
{
|
2017-04-09 11:19:35 +08:00
|
|
|
virtual Expected<std::string> read_contents(const fs::path& file_path) const = 0;
|
|
|
|
virtual Expected<std::vector<std::string>> read_all_lines(const fs::path& file_path) const = 0;
|
|
|
|
virtual fs::path find_file_recursively_up(const fs::path& starting_dir, const std::string& filename) const = 0;
|
|
|
|
virtual std::vector<fs::path> recursive_find_all_files_in_dir(const fs::path& dir) const = 0;
|
|
|
|
virtual std::vector<fs::path> non_recursive_find_all_files_in_dir(const fs::path& dir) const = 0;
|
|
|
|
|
|
|
|
virtual void write_all_lines(const fs::path& file_path, const std::vector<std::string>& lines) = 0;
|
|
|
|
virtual void rename(const fs::path& oldpath, const fs::path& newpath) = 0;
|
2017-04-12 06:16:39 +08:00
|
|
|
virtual bool remove(const fs::path& path) = 0;
|
|
|
|
virtual bool remove(const fs::path& path, std::error_code& ec) = 0;
|
|
|
|
virtual std::uintmax_t remove_all(const fs::path& path, std::error_code& ec) = 0;
|
2017-04-09 11:19:35 +08:00
|
|
|
virtual bool exists(const fs::path& path) const = 0;
|
|
|
|
virtual bool is_directory(const fs::path& path) const = 0;
|
|
|
|
virtual bool is_regular_file(const fs::path& path) const = 0;
|
|
|
|
virtual bool is_empty(const fs::path& path) const = 0;
|
|
|
|
virtual bool create_directory(const fs::path& path, std::error_code& ec) = 0;
|
|
|
|
virtual void copy(const fs::path& oldpath, const fs::path& newpath, fs::copy_options opts) = 0;
|
2017-04-12 06:16:39 +08:00
|
|
|
virtual bool copy_file(const fs::path& oldpath, const fs::path& newpath, fs::copy_options opts, std::error_code& ec) = 0;
|
|
|
|
virtual fs::file_status status(const fs::path& path, std::error_code& ec) const = 0;
|
2017-04-09 07:26:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Filesystem& get_real_filesystem();
|
|
|
|
|
2016-09-24 08:57:18 +08:00
|
|
|
static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)";
|
|
|
|
|
2016-12-17 11:38:02 +08:00
|
|
|
bool has_invalid_chars_for_filesystem(const std::string& s);
|
2016-09-24 08:57:18 +08:00
|
|
|
|
2016-12-01 06:08:43 +08:00
|
|
|
void print_paths(const std::vector<fs::path>& paths);
|
2017-01-06 04:47:08 +08:00
|
|
|
}
|