mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 03:24:09 +00:00
Revert create_symbolic_link and both depending changes
This reverts commits r203136, r203137, and r203138. This code doesn't build on Windows. Even on Vista+, Windows requires elevated privileges to create a symlink. Therefore we can't use symlinks in the compiler. We'll have to find another approach. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203143 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -293,14 +293,6 @@ error_code create_directory(const Twine &path, bool IgnoreExisting = true);
|
|||||||
/// , otherwise a platform specific error_code.
|
/// , otherwise a platform specific error_code.
|
||||||
error_code create_hard_link(const Twine &to, const Twine &from);
|
error_code create_hard_link(const Twine &to, const Twine &from);
|
||||||
|
|
||||||
/// @brief Create a symbolic link from \a from to \a to.
|
|
||||||
///
|
|
||||||
/// @param to The path to link to.
|
|
||||||
/// @param from The path to link from. This is created.
|
|
||||||
/// @returns errc::success if successful
|
|
||||||
/// , otherwise a platform specific error_code.
|
|
||||||
error_code create_symbolic_link(const Twine &to, const Twine &from);
|
|
||||||
|
|
||||||
/// @brief Get the current path.
|
/// @brief Get the current path.
|
||||||
///
|
///
|
||||||
/// @param result Holds the current path on return.
|
/// @param result Holds the current path on return.
|
||||||
|
@ -115,42 +115,34 @@ LockFileManager::LockFileManager(StringRef FileName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
// Create a hard link from the lock file name. If this succeeds, we're done.
|
||||||
// Create a symbolic link from the lock file name. If this succeeds, we're
|
error_code EC
|
||||||
// done. Note that we are using symbolic link because hard links are not
|
= sys::fs::create_hard_link(UniqueLockFileName.str(),
|
||||||
// supported by all filesystems.
|
LockFileName.str());
|
||||||
error_code EC
|
if (EC == errc::success)
|
||||||
= sys::fs::create_symbolic_link(UniqueLockFileName.str(),
|
return;
|
||||||
LockFileName.str());
|
|
||||||
if (EC == errc::success)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (EC != errc::file_exists) {
|
// Creating the hard link failed.
|
||||||
Error = EC;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Someone else managed to create the lock file first. Read the process ID
|
#ifdef LLVM_ON_UNIX
|
||||||
// from the lock file.
|
// The creation of the hard link may appear to fail, but if stat'ing the
|
||||||
if ((Owner = readLockFile(LockFileName))) {
|
// unique file returns a link count of 2, then we can still declare success.
|
||||||
// Wipe out our unique lock file (it's useless now)
|
struct stat StatBuf;
|
||||||
sys::fs::remove(UniqueLockFileName.str());
|
if (stat(UniqueLockFileName.c_str(), &StatBuf) == 0 &&
|
||||||
return;
|
StatBuf.st_nlink == 2)
|
||||||
}
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!sys::fs::exists(LockFileName.str())) {
|
// Someone else managed to create the lock file first. Wipe out our unique
|
||||||
// The previous owner released the lock file before we could read it.
|
// lock file (it's useless now) and read the process ID from the lock file.
|
||||||
// Try to get ownership again.
|
sys::fs::remove(UniqueLockFileName.str());
|
||||||
continue;
|
if ((Owner = readLockFile(LockFileName)))
|
||||||
}
|
return;
|
||||||
|
|
||||||
// There is a lock file that nobody owns; try to clean it up and get
|
// There is a lock file that nobody owns; try to clean it up and report
|
||||||
// ownership.
|
// an error.
|
||||||
if ((EC = sys::fs::remove(LockFileName.str()))) {
|
sys::fs::remove(LockFileName.str());
|
||||||
Error = EC;
|
Error = EC;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LockFileManager::LockFileState LockFileManager::getState() const {
|
LockFileManager::LockFileState LockFileManager::getState() const {
|
||||||
|
@ -285,19 +285,6 @@ error_code create_hard_link(const Twine &to, const Twine &from) {
|
|||||||
return error_code::success();
|
return error_code::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code create_symbolic_link(const Twine &to, const Twine &from) {
|
|
||||||
// Get arguments.
|
|
||||||
SmallString<128> from_storage;
|
|
||||||
SmallString<128> to_storage;
|
|
||||||
StringRef f = from.toNullTerminatedStringRef(from_storage);
|
|
||||||
StringRef t = to.toNullTerminatedStringRef(to_storage);
|
|
||||||
|
|
||||||
if (::symlink(t.begin(), f.begin()) == -1)
|
|
||||||
return error_code(errno, system_category());
|
|
||||||
|
|
||||||
return error_code::success();
|
|
||||||
}
|
|
||||||
|
|
||||||
error_code remove(const Twine &path, bool IgnoreNonExisting) {
|
error_code remove(const Twine &path, bool IgnoreNonExisting) {
|
||||||
SmallString<128> path_storage;
|
SmallString<128> path_storage;
|
||||||
StringRef p = path.toNullTerminatedStringRef(path_storage);
|
StringRef p = path.toNullTerminatedStringRef(path_storage);
|
||||||
|
@ -177,25 +177,6 @@ error_code create_hard_link(const Twine &to, const Twine &from) {
|
|||||||
return error_code::success();
|
return error_code::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code create_symbolic_link(const Twine &to, const Twine &from) {
|
|
||||||
// Get arguments.
|
|
||||||
SmallString<128> from_storage;
|
|
||||||
SmallString<128> to_storage;
|
|
||||||
StringRef f = from.toStringRef(from_storage);
|
|
||||||
StringRef t = to.toStringRef(to_storage);
|
|
||||||
|
|
||||||
// Convert to utf-16.
|
|
||||||
SmallVector<wchar_t, 128> wide_from;
|
|
||||||
SmallVector<wchar_t, 128> wide_to;
|
|
||||||
if (error_code ec = UTF8ToUTF16(f, wide_from)) return ec;
|
|
||||||
if (error_code ec = UTF8ToUTF16(t, wide_to)) return ec;
|
|
||||||
|
|
||||||
if (!::CreateSymbolicLinkW(wide_from.begin(), wide_to.begin(), NULL))
|
|
||||||
return windows_error(::GetLastError());
|
|
||||||
|
|
||||||
return error_code::success();
|
|
||||||
}
|
|
||||||
|
|
||||||
error_code remove(const Twine &path, bool IgnoreNonExisting) {
|
error_code remove(const Twine &path, bool IgnoreNonExisting) {
|
||||||
SmallString<128> path_storage;
|
SmallString<128> path_storage;
|
||||||
SmallVector<wchar_t, 128> path_utf16;
|
SmallVector<wchar_t, 128> path_utf16;
|
||||||
|
Reference in New Issue
Block a user