Use llvm::sys::fs::can_write.

llvm-svn: 184234
This commit is contained in:
Rafael Espindola 2013-06-18 20:58:25 +00:00
parent a1280c16fb
commit fc92e84586
2 changed files with 4 additions and 2 deletions

View File

@ -16,6 +16,7 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h" #include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/PathV1.h" #include "llvm/Support/PathV1.h"
#include "llvm/Support/Program.h" #include "llvm/Support/Program.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
@ -208,7 +209,7 @@ bool Compilation::CleanupFile(const char *File, bool IssueErrors) const {
// Don't try to remove files which we don't have write access to (but may be // Don't try to remove files which we don't have write access to (but may be
// able to remove), or non-regular files. Underlying tools may have // able to remove), or non-regular files. Underlying tools may have
// intentionally not overwritten them. // intentionally not overwritten them.
if (!P.canWrite() || !P.isRegularFile()) if (!llvm::sys::fs::can_write(File) || !P.isRegularFile())
return true; return true;
if (P.eraseFromDisk(false, &Error)) { if (P.eraseFromDisk(false, &Error)) {

View File

@ -535,7 +535,8 @@ CompilerInstance::createOutputFile(StringRef OutputPath,
bool Exists; bool Exists;
if ((CreateMissingDirectories || ParentExists) && if ((CreateMissingDirectories || ParentExists) &&
((llvm::sys::fs::exists(AbsPath.str(), Exists) || !Exists) || ((llvm::sys::fs::exists(AbsPath.str(), Exists) || !Exists) ||
(OutPath.isRegularFile() && OutPath.canWrite()))) { (OutPath.isRegularFile() &&
llvm::sys::fs::can_write(AbsPath.c_str())))) {
// Create a temporary file. // Create a temporary file.
SmallString<128> TempPath; SmallString<128> TempPath;
TempPath = OutFile; TempPath = OutFile;