diff options
author | Martin Storsjö <martin@martin.st> | 2020-11-04 23:51:18 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2021-02-03 09:23:58 +0200 |
commit | cdc60a3b9aa523b49329a7a5e4c1774d3b9e3db9 (patch) | |
tree | 3dc483cccb08a792b255cea867a482664df88e7e /libcxx/src/filesystem/operations.cpp | |
parent | 40117b700f723a27b90989a429ceb66c0873b161 (diff) | |
download | llvm-cdc60a3b9aa523b49329a7a5e4c1774d3b9e3db9.zip llvm-cdc60a3b9aa523b49329a7a5e4c1774d3b9e3db9.tar.gz llvm-cdc60a3b9aa523b49329a7a5e4c1774d3b9e3db9.tar.bz2 |
[libcxx] Implement the read_symlink function for windows
Differential Revision: https://reviews.llvm.org/D91172
Diffstat (limited to 'libcxx/src/filesystem/operations.cpp')
-rw-r--r-- | libcxx/src/filesystem/operations.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp index 47cd5e2..a5463e4 100644 --- a/libcxx/src/filesystem/operations.cpp +++ b/libcxx/src/filesystem/operations.cpp @@ -1227,21 +1227,25 @@ void __permissions(const path& p, perms prms, perm_options opts, path __read_symlink(const path& p, error_code* ec) { ErrorHandler<path> err("read_symlink", ec, &p); -#ifdef PATH_MAX +#if defined(PATH_MAX) || defined(MAX_SYMLINK_SIZE) struct NullDeleter { void operator()(void*) const {} }; +#ifdef MAX_SYMLINK_SIZE + const size_t size = MAX_SYMLINK_SIZE + 1; +#else const size_t size = PATH_MAX + 1; - char stack_buff[size]; - auto buff = std::unique_ptr<char[], NullDeleter>(stack_buff); +#endif + path::value_type stack_buff[size]; + auto buff = std::unique_ptr<path::value_type[], NullDeleter>(stack_buff); #else StatT sb; if (detail::lstat(p.c_str(), &sb) == -1) { return err.report(capture_errno()); } const size_t size = sb.st_size + 1; - auto buff = unique_ptr<char[]>(new char[size]); + auto buff = unique_ptr<path::value_type[]>(new path::value_type[size]); #endif - ::ssize_t ret; - if ((ret = ::readlink(p.c_str(), buff.get(), size)) == -1) + detail::SSizeT ret; + if ((ret = detail::readlink(p.c_str(), buff.get(), size)) == -1) return err.report(capture_errno()); _LIBCPP_ASSERT(ret > 0, "TODO"); if (static_cast<size_t>(ret) >= size) |