diff options
| author | Nicole Mazzuca <mazzucan@outlook.com> | 2019-08-20 18:43:51 -0700 |
|---|---|---|
| committer | nicole mazzuca <mazzucan@outlook.com> | 2019-08-23 07:01:03 -0700 |
| commit | cc35672763a340b4d6d836a2b9e4ec0e3d703e50 (patch) | |
| tree | 4bce349660d5b2fcda8c1e8e536a61bc3f237ffb /toolsrc/src | |
| parent | 78abf650e7797d28bcb4c4c94db47638a80c2005 (diff) | |
| download | vcpkg-cc35672763a340b4d6d836a2b9e4ec0e3d703e50.tar.gz vcpkg-cc35672763a340b4d6d836a2b9e4ec0e3d703e50.zip | |
(#7798) [vcpkg] Fix the build on FreeBSD 😈
Add a `#else` line to `toolsrc/src/vcpkg/base/files.cpp`. On Linux
and macOS, there are specific ways to copy from file descriptor to file
descriptor, but on FreeBSD there isn't (as far as I could tell). This
change does a copy using the POSIX standard `read` and `write` calls.
(This change was to `RealFilesystem::rename_or_copy`).
We expect to have people on FreeBSD install CMake themselves, and use
`./bootstrap.sh -useSystemBinaries`, in order to build vcpkg.
Since CMake 3.15.2 exists in the FreeBSD 12 (latest stable) package
manager, it's trivial to install it.
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg/base/files.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp index bbf37fd25..5ebe8d834 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -8,9 +8,8 @@ #include <vcpkg/base/util.h> #include <vcpkg/base/work_queue.h> -#if defined(__linux__) || defined(__APPLE__) +#if !defined(_WIN32) #include <fcntl.h> -#include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> @@ -396,7 +395,7 @@ namespace vcpkg::Files { this->rename(oldpath, newpath, ec); Util::unused(temp_suffix); -#if defined(__linux__) || defined(__APPLE__) +#if !defined(_WIN32) if (ec) { auto dst = newpath; @@ -419,6 +418,33 @@ namespace vcpkg::Files auto written_bytes = sendfile(o_fd, i_fd, &bytes, info.st_size); #elif defined(__APPLE__) auto written_bytes = fcopyfile(i_fd, o_fd, 0, COPYFILE_ALL); +#else + ssize_t written_bytes = 0; + { + constexpr std::size_t buffer_length = 4096; + auto buffer = std::make_unique<unsigned char[]>(buffer_length); + while (auto read_bytes = read(i_fd, buffer.get(), buffer_length)) + { + if (read_bytes == -1) + { + written_bytes = -1; + break; + } + auto remaining = read_bytes; + while (remaining > 0) { + auto read_result = write(o_fd, buffer.get(), remaining); + if (read_result == -1) + { + written_bytes = -1; + // break two loops + goto copy_failure; + } + remaining -= read_result; + } + } + + copy_failure: ; + } #endif if (written_bytes == -1) { |
