diff options
| author | LRFLEW <LRFLEW@aol.com> | 2018-10-17 12:46:27 -0600 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2018-10-17 11:46:27 -0700 |
| commit | 3d12e5ca72d948121463beec6e48290877684471 (patch) | |
| tree | 74d1edb1de757c0d0ce7adbaa99e376bc4adb336 /toolsrc/src | |
| parent | e7a37f14a82aaead89447c029f62c3427e07373c (diff) | |
| download | vcpkg-3d12e5ca72d948121463beec6e48290877684471.tar.gz vcpkg-3d12e5ca72d948121463beec6e48290877684471.zip | |
Handle symlink when installing or removing a library (#4479)
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg/base/files.cpp | 8 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/install.cpp | 19 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/remove.cpp | 4 |
3 files changed, 28 insertions, 3 deletions
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp index 4ff0912d1..f9bce8631 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -216,11 +216,19 @@ namespace vcpkg::Files { return fs::stdfs::copy_file(oldpath, newpath, opts, ec); } + virtual void copy_symlink(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) + { + return fs::stdfs::copy_symlink(oldpath, newpath, ec); + } virtual fs::file_status status(const fs::path& path, std::error_code& ec) const override { return fs::stdfs::status(path, ec); } + virtual fs::file_status symlink_status(const fs::path& path, std::error_code& ec) const override + { + return fs::stdfs::symlink_status(path, ec); + } virtual void write_contents(const fs::path& file_path, const std::string& data, std::error_code& ec) override { ec.clear(); diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index 4bb84831e..1cfa2bf71 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -62,7 +62,7 @@ namespace vcpkg::Install auto files = fs.get_files_recursive(source_dir); for (auto&& file : files) { - const auto status = fs.status(file, ec); + const auto status = fs.symlink_status(file, ec); if (ec) { System::println(System::Color::error, "failed: %s: %s", file.u8string(), ec.message()); @@ -111,6 +111,23 @@ namespace vcpkg::Install output.push_back(Strings::format(R"(%s/%s)", destination_subdirectory, suffix)); break; } + case fs::file_type::symlink: + { + if (fs.exists(target)) + { + System::println(System::Color::warning, + "File %s was already present and will be overwritten", + target.u8string(), + ec.message()); + } + fs.copy_symlink(file, target, ec); + if (ec) + { + System::println(System::Color::error, "failed: %s: %s", target.u8string(), ec.message()); + } + output.push_back(Strings::format(R"(%s/%s)", destination_subdirectory, suffix)); + break; + } default: System::println(System::Color::error, "failed: %s: cannot handle file type", file.u8string()); break; diff --git a/toolsrc/src/vcpkg/remove.cpp b/toolsrc/src/vcpkg/remove.cpp index 13cc9325e..921a04c23 100644 --- a/toolsrc/src/vcpkg/remove.cpp +++ b/toolsrc/src/vcpkg/remove.cpp @@ -55,7 +55,7 @@ namespace vcpkg::Remove auto target = paths.installed / suffix; - const auto status = fs.status(target, ec); + const auto status = fs.symlink_status(target, ec); if (ec) { System::println(System::Color::error, "failed: status(%s): %s", target.u8string(), ec.message()); @@ -66,7 +66,7 @@ namespace vcpkg::Remove { dirs_touched.push_back(target); } - else if (fs::is_regular_file(status)) + else if (fs::is_regular_file(status) || fs::is_symlink(status)) { fs.remove(target, ec); if (ec) |
