aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-04-11 15:16:39 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-04-11 15:16:39 -0700
commit0bc21296c9ef32412237a8cc0c8141d0226b9070 (patch)
treebe76ea0d3e3b2d8f469f8ff83fe2187d533efabd /toolsrc/src
parentb34c40a4e674f5db538e84ca2b9509482ac140e7 (diff)
downloadvcpkg-0bc21296c9ef32412237a8cc0c8141d0226b9070.tar.gz
vcpkg-0bc21296c9ef32412237a8cc0c8141d0226b9070.zip
[vcpkg] Alias out standard filesystem headers to ensure clean separation.
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/Paragraphs.cpp3
-rw-r--r--toolsrc/src/PostBuildLint.cpp16
-rw-r--r--toolsrc/src/VcpkgPaths.cpp9
-rw-r--r--toolsrc/src/commands_cache.cpp3
-rw-r--r--toolsrc/src/commands_edit.cpp10
-rw-r--r--toolsrc/src/commands_help.cpp5
-rw-r--r--toolsrc/src/commands_install.cpp18
-rw-r--r--toolsrc/src/commands_integrate.cpp32
-rw-r--r--toolsrc/src/commands_portsdiff.cpp6
-rw-r--r--toolsrc/src/commands_remove.cpp28
-rw-r--r--toolsrc/src/metrics.cpp11
-rw-r--r--toolsrc/src/vcpkg.cpp8
-rw-r--r--toolsrc/src/vcpkg_Files.cpp41
-rw-r--r--toolsrc/src/vcpkglib.cpp6
14 files changed, 111 insertions, 85 deletions
diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp
index 48095848d..9494656ed 100644
--- a/toolsrc/src/Paragraphs.cpp
+++ b/toolsrc/src/Paragraphs.cpp
@@ -237,9 +237,8 @@ namespace vcpkg::Paragraphs
std::vector<SourceParagraph> load_all_ports(const Files::Filesystem& fs, const fs::path& ports_dir)
{
std::vector<SourceParagraph> output;
- for (auto it = fs::directory_iterator(ports_dir); it != fs::directory_iterator(); ++it)
+ for (auto&& path : fs.non_recursive_find_all_files_in_dir(ports_dir))
{
- const fs::path& path = it->path();
Expected<SourceParagraph> source_paragraph = try_load_port(fs, path);
if (auto srcpgh = source_paragraph.get())
{
diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp
index 2229c6843..805fc8915 100644
--- a/toolsrc/src/PostBuildLint.cpp
+++ b/toolsrc/src/PostBuildLint.cpp
@@ -73,7 +73,7 @@ namespace vcpkg::PostBuildLint
return false;
}
- static LintStatus check_for_files_in_include_directory(const std::map<BuildPolicies::Type, OptBoolT>& policies, const fs::path& package_dir)
+ static LintStatus check_for_files_in_include_directory(const Files::Filesystem& fs, const std::map<BuildPolicies::Type, OptBoolT>& policies, const fs::path& package_dir)
{
if (contains_and_enabled(policies, BuildPolicies::EMPTY_INCLUDE_FOLDER))
{
@@ -81,7 +81,7 @@ namespace vcpkg::PostBuildLint
}
const fs::path include_dir = package_dir / "include";
- if (!fs::exists(include_dir) || fs::is_empty(include_dir))
+ if (!fs.exists(include_dir) || fs.is_empty(include_dir))
{
System::println(System::Color::warning, "The folder /include is empty. This indicates the library was not correctly installed.");
return LintStatus::ERROR_DETECTED;
@@ -657,7 +657,7 @@ namespace vcpkg::PostBuildLint
return error_count;
}
- error_count += check_for_files_in_include_directory(build_info.policies, package_dir);
+ error_count += check_for_files_in_include_directory(fs, build_info.policies, package_dir);
error_count += check_for_files_in_debug_include_directory(fs, package_dir);
error_count += check_for_files_in_debug_share_directory(fs, package_dir);
error_count += check_folder_lib_cmake(fs, package_dir, spec);
@@ -681,11 +681,13 @@ namespace vcpkg::PostBuildLint
error_count += check_matching_debug_and_release_binaries(debug_libs, release_libs);
- std::vector<fs::path> libs;
- libs.insert(libs.cend(), debug_libs.cbegin(), debug_libs.cend());
- libs.insert(libs.cend(), release_libs.cbegin(), release_libs.cend());
+ {
+ std::vector<fs::path> libs;
+ libs.insert(libs.cend(), debug_libs.cbegin(), debug_libs.cend());
+ libs.insert(libs.cend(), release_libs.cbegin(), release_libs.cend());
- error_count += check_lib_architecture(spec.target_triplet().architecture(), libs);
+ error_count += check_lib_architecture(spec.target_triplet().architecture(), libs);
+ }
switch (build_info.library_linkage)
{
diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp
index 84343a727..49f50f270 100644
--- a/toolsrc/src/VcpkgPaths.cpp
+++ b/toolsrc/src/VcpkgPaths.cpp
@@ -156,7 +156,7 @@ namespace vcpkg
Expected<VcpkgPaths> VcpkgPaths::create(const fs::path& vcpkg_root_dir)
{
std::error_code ec;
- const fs::path canonical_vcpkg_root_dir = fs::canonical(vcpkg_root_dir, ec);
+ const fs::path canonical_vcpkg_root_dir = fs::stdfs::canonical(vcpkg_root_dir, ec);
if (ec)
{
return ec;
@@ -214,10 +214,9 @@ namespace vcpkg
bool VcpkgPaths::is_valid_triplet(const Triplet& t) const
{
- auto it = fs::directory_iterator(this->triplets);
- for (; it != fs::directory_iterator(); ++it)
+ for (auto&& path : get_filesystem().non_recursive_find_all_files_in_dir(this->triplets))
{
- std::string triplet_file_name = it->path().stem().generic_u8string();
+ std::string triplet_file_name = path.stem().generic_u8string();
if (t.canonical_name() == triplet_file_name) // TODO: fuzzy compare
{
//t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
@@ -279,7 +278,7 @@ namespace vcpkg
// Skip any instances that do not have vcvarsall.
const fs::path vcvarsall_bat = vc_dir / "Auxiliary" / "Build" / "vcvarsall.bat";
paths_examined.push_back(vcvarsall_bat);
- if (!fs::exists(vcvarsall_bat))
+ if (!fs.exists(vcvarsall_bat))
continue;
// Locate the "best" MSVC toolchain version
diff --git a/toolsrc/src/commands_cache.cpp b/toolsrc/src/commands_cache.cpp
index 4c8690c1c..c7096b127 100644
--- a/toolsrc/src/commands_cache.cpp
+++ b/toolsrc/src/commands_cache.cpp
@@ -10,9 +10,8 @@ namespace vcpkg::Commands::Cache
static std::vector<BinaryParagraph> read_all_binary_paragraphs(const VcpkgPaths& paths)
{
std::vector<BinaryParagraph> output;
- for (auto it = fs::directory_iterator(paths.packages); it != fs::directory_iterator(); ++it)
+ for (auto&& path : paths.get_filesystem().non_recursive_find_all_files_in_dir(paths.packages))
{
- const fs::path& path = it->path();
const Expected<std::unordered_map<std::string, std::string>> pghs = Paragraphs::get_single_paragraph(paths.get_filesystem(), path / "CONTROL");
if (auto p = pghs.get())
{
diff --git a/toolsrc/src/commands_edit.cpp b/toolsrc/src/commands_edit.cpp
index 8549f5073..4679a2465 100644
--- a/toolsrc/src/commands_edit.cpp
+++ b/toolsrc/src/commands_edit.cpp
@@ -7,13 +7,15 @@ namespace vcpkg::Commands::Edit
{
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
+ auto& fs = paths.get_filesystem();
+
static const std::string example = Commands::Help::create_example_string("edit zlib");
args.check_exact_arg_count(1, example);
args.check_and_get_optional_command_arguments({});
const std::string port_name = args.command_arguments.at(0);
const fs::path portpath = paths.ports / port_name;
- Checks::check_exit(VCPKG_LINE_INFO, fs::is_directory(portpath), R"(Could not find port named "%s")", port_name);
+ Checks::check_exit(VCPKG_LINE_INFO, fs.is_directory(portpath), R"(Could not find port named "%s")", port_name);
// Find the user's selected editor
std::wstring env_EDITOR;
@@ -30,7 +32,7 @@ namespace vcpkg::Commands::Edit
if (env_EDITOR.empty())
{
const fs::path CODE_EXE_PATH = System::get_ProgramFiles_32_bit() / "Microsoft VS Code/Code.exe";
- if (fs::exists(CODE_EXE_PATH))
+ if (fs.exists(CODE_EXE_PATH))
{
env_EDITOR = CODE_EXE_PATH;
}
@@ -50,13 +52,13 @@ namespace vcpkg::Commands::Edit
if (auto c = code_installpath.get())
{
auto p = fs::path(*c) / "Code.exe";
- if (fs::exists(p))
+ if (fs.exists(p))
{
env_EDITOR = p.native();
break;
}
auto p_insiders = fs::path(*c) / "Code - Insiders.exe";
- if (fs::exists(p_insiders))
+ if (fs.exists(p_insiders))
{
env_EDITOR = p_insiders.native();
break;
diff --git a/toolsrc/src/commands_help.cpp b/toolsrc/src/commands_help.cpp
index e3c489a9d..e2e504fbf 100644
--- a/toolsrc/src/commands_help.cpp
+++ b/toolsrc/src/commands_help.cpp
@@ -7,10 +7,9 @@ namespace vcpkg::Commands::Help
void help_topic_valid_triplet(const VcpkgPaths& paths)
{
System::println("Available architecture triplets:");
- auto it = fs::directory_iterator(paths.triplets);
- for (; it != fs::directory_iterator(); ++it)
+ for (auto&& path : paths.get_filesystem().non_recursive_find_all_files_in_dir(paths.triplets))
{
- System::println(" %s", it->path().stem().filename().string());
+ System::println(" %s", path.stem().filename().string());
}
}
diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp
index bc253aaf2..87e95e499 100644
--- a/toolsrc/src/commands_install.cpp
+++ b/toolsrc/src/commands_install.cpp
@@ -30,24 +30,24 @@ namespace vcpkg::Commands::Install
fs.create_directory(paths.installed / target_triplet_as_string, ec);
output.push_back(Strings::format(R"(%s/)", target_triplet_as_string));
- // TODO: replace use of recursive_directory_iterator with filesystem abstraction.
- for (auto it = fs::recursive_directory_iterator(package_prefix_path); it != fs::recursive_directory_iterator(); ++it)
+ auto files = fs.recursive_find_all_files_in_dir(package_prefix_path);
+ for (auto&& file : files)
{
- auto status = it->status(ec);
+ auto status = fs.status(file, ec);
if (ec)
{
- System::println(System::Color::error, "failed: %s: %s", it->path().u8string(), ec.message());
+ System::println(System::Color::error, "failed: %s: %s", file.u8string(), ec.message());
continue;
}
- const std::string filename = it->path().filename().generic_string();
+ const std::string filename = file.filename().generic_string();
if (fs::is_regular_file(status) && (_stricmp(filename.c_str(), "CONTROL") == 0 || _stricmp(filename.c_str(), "BUILD_INFO") == 0))
{
// Do not copy the control file
continue;
}
- const std::string suffix = it->path().generic_u8string().substr(prefix_length + 1);
+ const std::string suffix = file.generic_u8string().substr(prefix_length + 1);
const fs::path target = paths.installed / target_triplet_as_string / suffix;
if (fs::is_directory(status))
@@ -69,7 +69,7 @@ namespace vcpkg::Commands::Install
{
System::println(System::Color::warning, "File %s was already present and will be overwritten", target.u8string(), ec.message());
}
- fs.copy_file(*it, target, fs::copy_options::overwrite_existing, ec);
+ fs.copy_file(file, target, fs::copy_options::overwrite_existing, ec);
if (ec)
{
System::println(System::Color::error, "failed: %s: %s", target.u8string(), ec.message());
@@ -80,11 +80,11 @@ namespace vcpkg::Commands::Install
if (!fs::status_known(status))
{
- System::println(System::Color::error, "failed: %s: unknown status", it->path().u8string());
+ System::println(System::Color::error, "failed: %s: unknown status", file.u8string());
continue;
}
- System::println(System::Color::error, "failed: %s: cannot handle file type", it->path().u8string());
+ System::println(System::Color::error, "failed: %s: cannot handle file type", file.u8string());
}
std::sort(output.begin(), output.end());
diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp
index 8d9ace8a4..60c6b0613 100644
--- a/toolsrc/src/commands_integrate.cpp
+++ b/toolsrc/src/commands_integrate.cpp
@@ -141,10 +141,12 @@ namespace vcpkg::Commands::Integrate
static void integrate_install(const VcpkgPaths& paths)
{
+ auto& fs = paths.get_filesystem();
+
// TODO: This block of code should eventually be removed
for (auto&& old_system_wide_targets_file : old_system_target_files)
{
- if (fs::exists(old_system_wide_targets_file))
+ if (fs.exists(old_system_wide_targets_file))
{
const std::string param = Strings::format(R"(/c DEL "%s" /Q > nul)", old_system_wide_targets_file.string());
ElevationPromptChoice user_choice = elevated_cmd_execute(param);
@@ -161,12 +163,13 @@ namespace vcpkg::Commands::Integrate
}
}
+ std::error_code ec;
const fs::path tmp_dir = paths.buildsystems / "tmp";
- fs::create_directory(paths.buildsystems);
- fs::create_directory(tmp_dir);
+ fs.create_directory(paths.buildsystems, ec);
+ fs.create_directory(tmp_dir, ec);
bool should_install_system = true;
- const Expected<std::string> system_wide_file_contents = paths.get_filesystem().read_contents(system_wide_targets_file);
+ const Expected<std::string> system_wide_file_contents = fs.read_contents(system_wide_targets_file);
if (auto contents_data = system_wide_file_contents.get())
{
std::regex re(R"###(<!-- version (\d+) -->)###");
@@ -198,14 +201,16 @@ namespace vcpkg::Commands::Integrate
Checks::unreachable(VCPKG_LINE_INFO);
}
- Checks::check_exit(VCPKG_LINE_INFO, fs::exists(system_wide_targets_file), "Error: failed to copy targets file to %s", system_wide_targets_file.string());
+ Checks::check_exit(VCPKG_LINE_INFO, fs.exists(system_wide_targets_file), "Error: failed to copy targets file to %s", system_wide_targets_file.string());
}
const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets";
std::ofstream(appdata_src_path) << create_appdata_targets_shortcut(paths.buildsystems_msbuild_targets.string());
auto appdata_dst_path = get_appdata_targets_path();
- if (!fs::copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing))
+ auto rc = fs.copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing, ec);
+
+ if (!rc || ec)
{
System::println(System::Color::error, "Error: Failed to copy file: %s -> %s", appdata_src_path.string(), appdata_dst_path.string());
Checks::exit_fail(VCPKG_LINE_INFO);
@@ -222,12 +227,12 @@ namespace vcpkg::Commands::Integrate
Checks::exit_success(VCPKG_LINE_INFO);
}
- static void integrate_remove()
+ static void integrate_remove(Files::Filesystem& fs)
{
const fs::path path = get_appdata_targets_path();
std::error_code ec;
- bool was_deleted = fs::remove(path, ec);
+ bool was_deleted = fs.remove(path, ec);
Checks::check_exit(VCPKG_LINE_INFO, !ec, "Error: Unable to remove user-wide integration: %d", ec.message());
@@ -245,12 +250,15 @@ namespace vcpkg::Commands::Integrate
static void integrate_project(const VcpkgPaths& paths)
{
+ auto& fs = paths.get_filesystem();
+
const fs::path& nuget_exe = paths.get_nuget_exe();
const fs::path& buildsystems_dir = paths.buildsystems;
const fs::path tmp_dir = buildsystems_dir / "tmp";
- fs::create_directory(buildsystems_dir);
- fs::create_directory(tmp_dir);
+ std::error_code ec;
+ fs.create_directory(buildsystems_dir, ec);
+ fs.create_directory(tmp_dir, ec);
const fs::path targets_file_path = tmp_dir / "vcpkg.nuget.targets";
const fs::path props_file_path = tmp_dir / "vcpkg.nuget.props";
@@ -268,7 +276,7 @@ namespace vcpkg::Commands::Integrate
const int exit_code = System::cmd_execute_clean(cmd_line);
const fs::path nuget_package = buildsystems_dir / Strings::format("%s.%s.nupkg", nuget_id, nupkg_version);
- Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0 && fs::exists(nuget_package), "Error: NuGet package creation failed");
+ Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0 && fs.exists(nuget_package), "Error: NuGet package creation failed");
System::println(System::Color::success, "Created nupkg: %s", nuget_package.string());
System::println(R"(
@@ -297,7 +305,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
}
if (args.command_arguments[0] == "remove")
{
- return integrate_remove();
+ return integrate_remove(paths.get_filesystem());
}
if (args.command_arguments[0] == "project")
{
diff --git a/toolsrc/src/commands_portsdiff.cpp b/toolsrc/src/commands_portsdiff.cpp
index 2f8d37eb3..e262a8338 100644
--- a/toolsrc/src/commands_portsdiff.cpp
+++ b/toolsrc/src/commands_portsdiff.cpp
@@ -69,11 +69,13 @@ namespace vcpkg::Commands::PortsDiff
static std::map<std::string, VersionT> read_ports_from_commit(const VcpkgPaths& paths, const std::wstring& git_commit_id)
{
+ std::error_code ec;
+ auto& fs = paths.get_filesystem();
const fs::path& git_exe = paths.get_git_exe();
const fs::path dot_git_dir = paths.root / ".git";
const std::wstring ports_dir_name_as_string = paths.ports.filename().native();
const fs::path temp_checkout_path = paths.root / Strings::wformat(L"%s-%s", ports_dir_name_as_string, git_commit_id);
- fs::create_directory(temp_checkout_path);
+ fs.create_directory(temp_checkout_path, ec);
const std::wstring checkout_this_dir = Strings::wformat(LR"(.\%s)", ports_dir_name_as_string); // Must be relative to the root of the repository
const std::wstring cmd = Strings::wformat(LR"("%s" --git-dir="%s" --work-tree="%s" checkout %s -f -q -- %s %s & "%s" reset >NUL)",
@@ -87,7 +89,7 @@ namespace vcpkg::Commands::PortsDiff
System::cmd_execute_clean(cmd);
const std::vector<SourceParagraph> source_paragraphs = Paragraphs::load_all_ports(paths.get_filesystem(), temp_checkout_path / ports_dir_name_as_string);
const std::map<std::string, VersionT> names_and_versions = Paragraphs::extract_port_names_and_versions(source_paragraphs);
- fs::remove_all(temp_checkout_path);
+ fs.remove_all(temp_checkout_path, ec);
return names_and_versions;
}
diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp
index 8bf2c767b..fe4aede13 100644
--- a/toolsrc/src/commands_remove.cpp
+++ b/toolsrc/src/commands_remove.cpp
@@ -13,15 +13,15 @@ namespace vcpkg::Commands::Remove
using Dependencies::RequestType;
using Update::OutdatedPackage;
- static void delete_directory(const fs::path& directory)
+ static void delete_directory(Files::Filesystem& fs, const fs::path& directory)
{
std::error_code ec;
- fs::remove_all(directory, ec);
+ fs.remove_all(directory, ec);
if (!ec)
{
System::println(System::Color::success, "Cleaned up %s", directory.string());
}
- if (fs::exists(directory))
+ if (fs.exists(directory))
{
System::println(System::Color::warning, "Some files in %s were unable to be removed. Close any editors operating in this directory and retry.", directory.string());
}
@@ -29,18 +29,19 @@ namespace vcpkg::Commands::Remove
static void remove_package(const VcpkgPaths& paths, const PackageSpec& spec, StatusParagraphs* status_db)
{
+ auto& fs = paths.get_filesystem();
StatusParagraph& pkg = **status_db->find(spec.name(), spec.target_triplet());
pkg.want = Want::PURGE;
pkg.state = InstallState::HALF_INSTALLED;
write_update(paths, pkg);
- std::fstream listfile(paths.listfile_path(pkg.package), std::ios_base::in | std::ios_base::binary);
- if (listfile)
+ auto maybe_lines = fs.read_all_lines(paths.listfile_path(pkg.package));
+
+ if (auto lines = maybe_lines.get())
{
std::vector<fs::path> dirs_touched;
- std::string suffix;
- while (std::getline(listfile, suffix))
+ for (auto&& suffix : *lines)
{
if (!suffix.empty() && suffix.back() == '\r')
suffix.pop_back();
@@ -49,7 +50,7 @@ namespace vcpkg::Commands::Remove
auto target = paths.installed / suffix;
- auto status = fs::status(target, ec);
+ auto status = fs.status(target, ec);
if (ec)
{
System::println(System::Color::error, "failed: %s", ec.message());
@@ -62,7 +63,7 @@ namespace vcpkg::Commands::Remove
}
else if (fs::is_regular_file(status))
{
- fs::remove(target, ec);
+ fs.remove(target, ec);
if (ec)
{
System::println(System::Color::error, "failed: %s: %s", target.u8string(), ec.message());
@@ -82,10 +83,10 @@ namespace vcpkg::Commands::Remove
auto e = dirs_touched.rend();
for (; b != e; ++b)
{
- if (fs::directory_iterator(*b) == fs::directory_iterator())
+ if (fs.is_empty(*b))
{
std::error_code ec;
- fs::remove(*b, ec);
+ fs.remove(*b, ec);
if (ec)
{
System::println(System::Color::error, "failed: %s", ec.message());
@@ -93,8 +94,7 @@ namespace vcpkg::Commands::Remove
}
}
- listfile.close();
- fs::remove(paths.listfile_path(pkg.package));
+ fs.remove(paths.listfile_path(pkg.package));
}
pkg.state = InstallState::NOT_INSTALLED;
@@ -220,7 +220,7 @@ namespace vcpkg::Commands::Remove
if (alsoRemoveFolderFromPackages)
{
System::println("Purging package %s... ", display_name);
- delete_directory(paths.packages / action.spec.dir());
+ delete_directory(paths.get_filesystem(), paths.packages / action.spec.dir());
System::println(System::Color::success, "Purging package %s... done", display_name);
}
}
diff --git a/toolsrc/src/metrics.cpp b/toolsrc/src/metrics.cpp
index 515d7e574..cfdd418c3 100644
--- a/toolsrc/src/metrics.cpp
+++ b/toolsrc/src/metrics.cpp
@@ -3,6 +3,7 @@
#include "filesystem_fs.h"
#include "vcpkg_Strings.h"
#include "vcpkg_System.h"
+#include "vcpkg_Files.h"
namespace vcpkg::Metrics
{
@@ -385,24 +386,26 @@ true
const fs::path temp_folder_path = temp_folder;
const fs::path temp_folder_path_exe = temp_folder_path / "vcpkgmetricsuploader.exe";
+ auto& fs = Files::get_real_filesystem();
+
if (true)
{
- const fs::path exe_path = []() -> fs::path
+ const fs::path exe_path = [&fs]() -> fs::path
{
auto vcpkgdir = get_bindir().parent_path();
auto path = vcpkgdir / "vcpkgmetricsuploader.exe";
- if (fs::exists(path))
+ if (fs.exists(path))
return path;
path = vcpkgdir / "scripts" / "vcpkgmetricsuploader.exe";
- if (fs::exists(path))
+ if (fs.exists(path))
return path;
return L"";
}();
std::error_code ec;
- fs::copy_file(exe_path, temp_folder_path_exe, fs::copy_options::skip_existing, ec);
+ fs.copy_file(exe_path, temp_folder_path_exe, fs::copy_options::skip_existing, ec);
if (ec)
return;
}
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index b2942603f..8cb2806d6 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -41,18 +41,18 @@ static void inner(const VcpkgCmdArguments& args)
fs::path vcpkg_root_dir;
if (args.vcpkg_root_dir != nullptr)
{
- vcpkg_root_dir = fs::absolute(Strings::utf8_to_utf16(*args.vcpkg_root_dir));
+ vcpkg_root_dir = fs::stdfs::absolute(Strings::utf8_to_utf16(*args.vcpkg_root_dir));
}
else
{
const Optional<std::wstring> vcpkg_root_dir_env = System::get_environmental_variable(L"VCPKG_ROOT");
if (auto v = vcpkg_root_dir_env.get())
{
- vcpkg_root_dir = fs::absolute(*v);
+ vcpkg_root_dir = fs::stdfs::absolute(*v);
}
else
{
- vcpkg_root_dir = Files::get_real_filesystem().find_file_recursively_up(fs::absolute(System::get_exe_path_of_current_process()), ".vcpkg-root");
+ vcpkg_root_dir = Files::get_real_filesystem().find_file_recursively_up(fs::stdfs::absolute(System::get_exe_path_of_current_process()), ".vcpkg-root");
}
}
@@ -144,7 +144,7 @@ static void loadConfig()
try
{
std::error_code ec;
- fs::create_directory(localappdata / "vcpkg", ec);
+ Files::get_real_filesystem().create_directory(localappdata / "vcpkg", ec);
std::ofstream(localappdata / "vcpkg" / "config", std::ios_base::out | std::ios_base::trunc)
<< "User-Id: " << user_id << "\n"
<< "User-Since: " << user_time << "\n";
diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp
index 4e83300f4..a4a637b78 100644
--- a/toolsrc/src/vcpkg_Files.cpp
+++ b/toolsrc/src/vcpkg_Files.cpp
@@ -56,7 +56,7 @@ namespace vcpkg::Files
for (; !current_dir.empty(); current_dir = current_dir.parent_path())
{
const fs::path candidate = current_dir / filename;
- if (fs::exists(candidate))
+ if (exists(candidate))
{
break;
}
@@ -69,7 +69,7 @@ namespace vcpkg::Files
{
std::vector<fs::path> ret;
- fs::recursive_directory_iterator b(dir), e{};
+ fs::stdfs::recursive_directory_iterator b(dir), e{};
for (; b != e; ++b)
{
ret.push_back(b->path());
@@ -81,7 +81,7 @@ namespace vcpkg::Files
{
std::vector<fs::path> ret;
- fs::directory_iterator b(dir), e{};
+ fs::stdfs::directory_iterator b(dir), e{};
for (; b != e; ++b)
{
ret.push_back(b->path());
@@ -102,39 +102,52 @@ namespace vcpkg::Files
virtual void rename(const fs::path & oldpath, const fs::path & newpath) override
{
- fs::rename(oldpath, newpath);
+ fs::stdfs::rename(oldpath, newpath);
}
- virtual void remove(const fs::path & path) override
+ virtual bool remove(const fs::path & path) override
{
- fs::remove(path);
+ return fs::stdfs::remove(path);
+ }
+ virtual bool remove(const fs::path & path, std::error_code& ec) override
+ {
+ return fs::stdfs::remove(path, ec);
+ }
+ virtual std::uintmax_t remove_all(const fs::path & path, std::error_code& ec) override
+ {
+ return fs::stdfs::remove_all(path, ec);
}
virtual bool exists(const fs::path & path) const override
{
- return fs::exists(path);
+ return fs::stdfs::exists(path);
}
virtual bool is_directory(const fs::path & path) const override
{
- return fs::is_directory(path);
+ return fs::stdfs::is_directory(path);
}
virtual bool is_regular_file(const fs::path & path) const override
{
- return fs::is_regular_file(path);
+ return fs::stdfs::is_regular_file(path);
}
virtual bool is_empty(const fs::path & path) const override
{
- return fs::is_empty(path);
+ return fs::stdfs::is_empty(path);
}
virtual bool create_directory(const fs::path & path, std::error_code & ec) override
{
- return fs::create_directory(path, ec);
+ return fs::stdfs::create_directory(path, ec);
}
virtual void copy(const fs::path & oldpath, const fs::path & newpath, fs::copy_options opts) override
{
- fs::copy(oldpath, newpath, opts);
+ fs::stdfs::copy(oldpath, newpath, opts);
}
- virtual void copy_file(const fs::path & oldpath, const fs::path & newpath, fs::copy_options opts, std::error_code & ec) override
+ virtual bool copy_file(const fs::path & oldpath, const fs::path & newpath, fs::copy_options opts, std::error_code & ec) override
+ {
+ return fs::stdfs::copy_file(oldpath, newpath, opts, ec);
+ }
+
+ virtual fs::file_status status(const fs::path& path, std::error_code& ec) const override
{
- fs::copy_file(oldpath, newpath, opts, ec);
+ return fs::stdfs::status(path, ec);
}
};
diff --git a/toolsrc/src/vcpkglib.cpp b/toolsrc/src/vcpkglib.cpp
index ab3c19721..ad359612e 100644
--- a/toolsrc/src/vcpkglib.cpp
+++ b/toolsrc/src/vcpkglib.cpp
@@ -12,15 +12,15 @@ namespace vcpkg
static StatusParagraphs load_current_database(Files::Filesystem& fs, const fs::path& vcpkg_dir_status_file, const fs::path& vcpkg_dir_status_file_old)
{
- if (!fs::exists(vcpkg_dir_status_file))
+ if (!fs.exists(vcpkg_dir_status_file))
{
- if (!fs::exists(vcpkg_dir_status_file_old))
+ if (!fs.exists(vcpkg_dir_status_file_old))
{
// no status file, use empty db
return StatusParagraphs();
}
- fs::rename(vcpkg_dir_status_file_old, vcpkg_dir_status_file);
+ fs.rename(vcpkg_dir_status_file_old, vcpkg_dir_status_file);
}
auto pghs = Paragraphs::get_paragraphs(fs, vcpkg_dir_status_file).value_or_exit(VCPKG_LINE_INFO);