diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-03-21 01:25:37 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-03-21 01:25:37 +0000 |
commit | 2c8cd9a0baa99a66ebde72dc688ef3e9239890e0 (patch) | |
tree | 38ff0c58ae6367871e3571fe334a077259d3e030 /lib/Support/Unix/Path.inc | |
parent | 5b460ed4cdba9575891757b1796c0a6368b7d942 (diff) | |
download | llvm-2c8cd9a0baa99a66ebde72dc688ef3e9239890e0.tar.gz llvm-2c8cd9a0baa99a66ebde72dc688ef3e9239890e0.tar.bz2 llvm-2c8cd9a0baa99a66ebde72dc688ef3e9239890e0.tar.xz |
[Support] Make sure sys::fs::remove can remove symbolic links and make sure LockFileManager can handle a symbolic link that points nowhere.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix/Path.inc')
-rw-r--r-- | lib/Support/Unix/Path.inc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc index 500b7fecb7..1c91053610 100644 --- a/lib/Support/Unix/Path.inc +++ b/lib/Support/Unix/Path.inc @@ -305,7 +305,7 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) { StringRef p = path.toNullTerminatedStringRef(path_storage); struct stat buf; - if (stat(p.begin(), &buf) != 0) { + if (lstat(p.begin(), &buf) != 0) { if (errno != errc::no_such_file_or_directory || !IgnoreNonExisting) return error_code(errno, system_category()); return error_code::success(); @@ -316,7 +316,7 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) { // check ensures that what we're trying to erase is a regular file. It // effectively prevents LLVM from erasing things like /dev/null, any block // special file, or other things that aren't "regular" files. - if (!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) + if (!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode) && !S_ISLNK(buf.st_mode)) return make_error_code(errc::operation_not_permitted); if (::remove(p.begin()) == -1) { |