X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FUnix%2FPathV2.inc;h=f7ca64daf7e9bf578a60d785d702f8408773f5b6;hb=1522fce477f3b6b1b5812aa561ad2ff3f51eb968;hp=b5cf724c5ff862eb256034fdda11eed6f88e537f;hpb=3890e397c3fa6cc11f50ea5e32ca81afa1e653a5;p=oota-llvm.git diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index b5cf724c5ff..f7ca64daf7e 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -69,24 +69,26 @@ namespace { namespace llvm { namespace sys { -namespace path { +namespace fs { error_code current_path(SmallVectorImpl &result) { - long size = ::pathconf(".", _PC_PATH_MAX); - result.reserve(size + 1); - result.set_size(size + 1); - - if (::getcwd(result.data(), result.size()) == 0) - return error_code(errno, system_category()); + result.reserve(MAXPATHLEN); + + 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;