mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Support/PathV2: Move current_path from path to fs and fix the Unix implementation.
Unix bug spotted by Dan Gohman. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121090 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
+12
-10
@@ -69,24 +69,26 @@ namespace {
|
||||
|
||||
namespace llvm {
|
||||
namespace sys {
|
||||
namespace path {
|
||||
namespace fs {
|
||||
|
||||
error_code current_path(SmallVectorImpl<char> &result) {
|
||||
long size = ::pathconf(".", _PC_PATH_MAX);
|
||||
result.reserve(size + 1);
|
||||
result.set_size(size + 1);
|
||||
result.reserve(MAXPATHLEN);
|
||||
|
||||
if (::getcwd(result.data(), result.size()) == 0)
|
||||
return error_code(errno, system_category());
|
||||
while (true) {
|
||||
if (::getcwd(result.data(), result.capacity()) == 0) {
|
||||
// See if there was a real error.
|
||||
if (errno != errc::not_enough_memory)
|
||||
return error_code(errno, system_category());
|
||||
// Otherwise there just wasn't enough space.
|
||||
result.reserve(result.capacity() * 2);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
result.set_size(strlen(result.data()));
|
||||
return success;
|
||||
}
|
||||
|
||||
} // end namespace path
|
||||
|
||||
namespace fs{
|
||||
|
||||
error_code copy_file(const Twine &from, const Twine &to, copy_option copt) {
|
||||
// Get arguments.
|
||||
SmallString<128> from_storage;
|
||||
|
||||
Reference in New Issue
Block a user