mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-08 08:54:58 +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:
parent
3890e397c3
commit
1522fce477
@ -148,6 +148,13 @@ error_code create_hard_link(const Twine &to, const Twine &from);
|
|||||||
/// otherwise a platform specific error_code.
|
/// otherwise a platform specific error_code.
|
||||||
error_code create_symlink(const Twine &to, const Twine &from);
|
error_code create_symlink(const Twine &to, const Twine &from);
|
||||||
|
|
||||||
|
/// @brief Get the current path.
|
||||||
|
///
|
||||||
|
/// @param result Holds the current path on return.
|
||||||
|
/// @results errc::success if the current path has been stored in result,
|
||||||
|
/// otherwise a platform specific error_code.
|
||||||
|
error_code current_path(SmallVectorImpl<char> &result);
|
||||||
|
|
||||||
/// @brief Remove path. Equivalent to POSIX remove().
|
/// @brief Remove path. Equivalent to POSIX remove().
|
||||||
///
|
///
|
||||||
/// @param path Input path.
|
/// @param path Input path.
|
||||||
|
@ -202,15 +202,6 @@ error_code native(const Twine &path, SmallVectorImpl<char> &result);
|
|||||||
/// @name Lexical Observers
|
/// @name Lexical Observers
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/// @brief Get the current path.
|
|
||||||
///
|
|
||||||
/// @param result Holds the current path on return.
|
|
||||||
/// @results errc::success if the current path has been stored in result,
|
|
||||||
/// otherwise a platform specific error_code.
|
|
||||||
error_code current_path(SmallVectorImpl<char> &result);
|
|
||||||
|
|
||||||
// The following are purely lexical.
|
|
||||||
|
|
||||||
/// @brief Get root name.
|
/// @brief Get root name.
|
||||||
///
|
///
|
||||||
/// //net/hello => //net
|
/// //net/hello => //net
|
||||||
|
@ -437,7 +437,7 @@ error_code make_absolute(SmallVectorImpl<char> &path) {
|
|||||||
|
|
||||||
// All of the following conditions will need the current directory.
|
// All of the following conditions will need the current directory.
|
||||||
SmallString<128> current_dir;
|
SmallString<128> current_dir;
|
||||||
if (error_code ec = current_path(current_dir)) return ec;
|
if (error_code ec = fs::current_path(current_dir)) return ec;
|
||||||
|
|
||||||
// Relative path. Prepend the current directory.
|
// Relative path. Prepend the current directory.
|
||||||
if (!rootName && !rootDirectory) {
|
if (!rootName && !rootDirectory) {
|
||||||
|
@ -69,24 +69,26 @@ namespace {
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace sys {
|
namespace sys {
|
||||||
namespace path {
|
namespace fs {
|
||||||
|
|
||||||
error_code current_path(SmallVectorImpl<char> &result) {
|
error_code current_path(SmallVectorImpl<char> &result) {
|
||||||
long size = ::pathconf(".", _PC_PATH_MAX);
|
result.reserve(MAXPATHLEN);
|
||||||
result.reserve(size + 1);
|
|
||||||
result.set_size(size + 1);
|
|
||||||
|
|
||||||
if (::getcwd(result.data(), result.size()) == 0)
|
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());
|
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()));
|
result.set_size(strlen(result.data()));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace path
|
|
||||||
|
|
||||||
namespace fs{
|
|
||||||
|
|
||||||
error_code copy_file(const Twine &from, const Twine &to, copy_option copt) {
|
error_code copy_file(const Twine &from, const Twine &to, copy_option copt) {
|
||||||
// Get arguments.
|
// Get arguments.
|
||||||
SmallString<128> from_storage;
|
SmallString<128> from_storage;
|
||||||
|
@ -134,7 +134,7 @@ namespace {
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace sys {
|
namespace sys {
|
||||||
namespace path {
|
namespace fs {
|
||||||
|
|
||||||
error_code current_path(SmallVectorImpl<char> &result) {
|
error_code current_path(SmallVectorImpl<char> &result) {
|
||||||
SmallVector<wchar_t, 128> cur_path;
|
SmallVector<wchar_t, 128> cur_path;
|
||||||
@ -180,10 +180,6 @@ retry_cur_dir:
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace path
|
|
||||||
|
|
||||||
namespace fs {
|
|
||||||
|
|
||||||
error_code copy_file(const Twine &from, const Twine &to, copy_option copt) {
|
error_code copy_file(const Twine &from, const Twine &to, copy_option copt) {
|
||||||
// Get arguments.
|
// Get arguments.
|
||||||
SmallString<128> from_storage;
|
SmallString<128> from_storage;
|
||||||
|
Loading…
Reference in New Issue
Block a user