aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-04-19 13:49:51 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-04-20 14:10:57 -0700
commit2cccd03966969a376f60e6b8658e1db60a2c2a6f (patch)
tree8018b318b412ea8779d4ba60001a900a6964f182
parentd0a1206050d2aa42981244d8dbc744bb1093db34 (diff)
downloadvcpkg-2cccd03966969a376f60e6b8658e1db60a2c2a6f.tar.gz
vcpkg-2cccd03966969a376f60e6b8658e1db60a2c2a6f.zip
Simplify InstallDirs class. No longer touches disk
-rw-r--r--toolsrc/include/vcpkg_Commands.h3
-rw-r--r--toolsrc/src/commands_install.cpp27
2 files changed, 12 insertions, 18 deletions
diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h
index ef6020e1a..40c15688e 100644
--- a/toolsrc/include/vcpkg_Commands.h
+++ b/toolsrc/include/vcpkg_Commands.h
@@ -45,8 +45,7 @@ namespace vcpkg::Commands
{
struct InstallationDirs
{
- static InstallationDirs initiliaze(Files::Filesystem& fs,
- const fs::path& source_dir,
+ static InstallationDirs initiliaze(const fs::path& source_dir,
const fs::path& destination_root,
const std::string& destination_subdirectory,
const fs::path& listfile);
diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp
index e8073cb77..25e2557cf 100644
--- a/toolsrc/src/commands_install.cpp
+++ b/toolsrc/src/commands_install.cpp
@@ -15,8 +15,7 @@ namespace vcpkg::Commands::Install
using Dependencies::RequestType;
using Dependencies::InstallPlanType;
- InstallationDirs InstallationDirs::initiliaze(Files::Filesystem& fs,
- const fs::path& source_dir,
+ InstallationDirs InstallationDirs::initiliaze(const fs::path& source_dir,
const fs::path& destination_root,
const std::string& destination_subdirectory,
const fs::path& listfile)
@@ -26,17 +25,6 @@ namespace vcpkg::Commands::Install
dirs.m_destination = destination_root / destination_subdirectory;
dirs.m_destination_subdirectory = destination_subdirectory;
dirs.m_listfile = listfile;
-
- std::error_code ec;
- Checks::check_exit(VCPKG_LINE_INFO, fs.exists(dirs.source_dir()), "Source directory %s does not exist", dirs.source_dir().generic_string());
-
- fs.create_directories(dirs.destination(), ec);
- Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create destination directory %s", dirs.destination().generic_string());
-
- const fs::path listfile_parent = dirs.listfile().parent_path();
- fs.create_directories(listfile_parent, ec);
- Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for listfile %s", dirs.listfile().generic_string());
-
return dirs;
}
@@ -69,6 +57,14 @@ namespace vcpkg::Commands::Install
const size_t prefix_length = source_dir.native().size();
const fs::path& destination = dirs.destination();
const std::string& destination_subdirectory = dirs.destination_subdirectory();
+ const fs::path& listfile = dirs.listfile();
+
+ Checks::check_exit(VCPKG_LINE_INFO, fs.exists(source_dir), "Source directory %s does not exist", source_dir.generic_string());
+ fs.create_directories(destination, ec);
+ Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create destination directory %s", destination.generic_string());
+ const fs::path listfile_parent = listfile.parent_path();
+ fs.create_directories(listfile_parent, ec);
+ Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create directory for listfile %s", listfile.generic_string());
output.push_back(Strings::format(R"(%s/)", destination_subdirectory));
auto files = fs.get_files_recursive(source_dir);
@@ -130,7 +126,7 @@ namespace vcpkg::Commands::Install
std::sort(output.begin(), output.end());
- fs.write_lines(dirs.listfile(), output);
+ fs.write_lines(listfile, output);
}
static void remove_first_n_chars(std::vector<std::string>* strings, const size_t n)
@@ -260,8 +256,7 @@ namespace vcpkg::Commands::Install
write_update(paths, source_paragraph);
status_db->insert(std::make_unique<StatusParagraph>(source_paragraph));
- const InstallationDirs dirs = InstallationDirs::initiliaze(paths.get_filesystem(),
- package_dir,
+ const InstallationDirs dirs = InstallationDirs::initiliaze(package_dir,
paths.installed,
triplet.to_string(),
paths.listfile_path(binary_paragraph));