aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/commands_install.cpp
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-04-17 18:18:47 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-04-17 19:04:17 -0700
commit4da39c6ca6e70734abe7b3d880e6987b7783fe36 (patch)
tree83152d912ac6c1fcc047b793b71e1b64e8498b5d /toolsrc/src/commands_install.cpp
parentc8ff4e39ba313b7ad6d3daa0d604e5f648a04d71 (diff)
downloadvcpkg-4da39c6ca6e70734abe7b3d880e6987b7783fe36.tar.gz
vcpkg-4da39c6ca6e70734abe7b3d880e6987b7783fe36.zip
InstallationDirs struct now checks/create the needed dirs
Diffstat (limited to 'toolsrc/src/commands_install.cpp')
-rw-r--r--toolsrc/src/commands_install.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp
index 05d1e32eb..8c7ffba7e 100644
--- a/toolsrc/src/commands_install.cpp
+++ b/toolsrc/src/commands_install.cpp
@@ -15,15 +15,44 @@ namespace vcpkg::Commands::Install
using Dependencies::RequestType;
using Dependencies::InstallPlanType;
+ InstallationDirs InstallationDirs::initiliaze_dirs(Files::Filesystem& fs,
+ const fs::path& source_dir,
+ const fs::path& destination_root,
+ const std::string& destination_subdirectory,
+ const fs::path& listfile)
+ {
+ std::error_code ec;
+ InstallationDirs dirs;
+ dirs.source_dir = source_dir;
+ Checks::check_exit(VCPKG_LINE_INFO, fs.exists(dirs.source_dir), "Source directory %s does not exist", dirs.source_dir.generic_string());
+
+ dirs.destination_root = destination_root;
+ dirs.destination_subdirectory = destination_subdirectory;
+ const fs::path destination = dirs.destination_root / dirs.destination_subdirectory;
+ fs.create_directories(destination, ec);
+ Checks::check_exit(VCPKG_LINE_INFO, !ec, "Could not create destination directory %s", destination.generic_string());
+
+ dirs.listfile = listfile;
+ 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", dirs.listfile.generic_string());
+
+ return dirs;
+ }
+
+ fs::path InstallationDirs::destination() const
+ {
+ return this->destination_root / this->destination_subdirectory;
+ }
+
void install_files_and_write_listfile(Files::Filesystem& fs, const InstallationDirs& dirs)
{
std::vector<std::string> output;
const size_t prefix_length = dirs.source_dir.native().size();
- const fs::path destination = dirs.destination_root / dirs.destination_subdirectory;
+ const fs::path destination = dirs.destination();
std::error_code ec;
- fs.create_directory(destination, ec);
output.push_back(Strings::format(R"(%s/)", dirs.destination_subdirectory));
auto files = fs.get_files_recursive(dirs.source_dir);