diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2006-08-22 23:27:23 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2006-08-22 23:27:23 +0000 |
| commit | 9d2f19c7e47e758be119027f16e4fc1b039271f7 (patch) | |
| tree | 78eac4c0057f94feb2a32cac0531043939eb8efc | |
| parent | 9afdac4a559655fe11e24b031fa081951eb0b0f3 (diff) | |
| download | bcm5719-llvm-9d2f19c7e47e758be119027f16e4fc1b039271f7.tar.gz bcm5719-llvm-9d2f19c7e47e758be119027f16e4fc1b039271f7.zip | |
For PR797:
Change the Path::make*OnDisk methods exception free and adjust their usage.
llvm-svn: 29836
| -rw-r--r-- | llvm/include/llvm/System/Path.h | 8 | ||||
| -rw-r--r-- | llvm/lib/System/Unix/Path.inc | 27 | ||||
| -rw-r--r-- | llvm/tools/gccld/gccld.cpp | 18 | ||||
| -rw-r--r-- | llvm/tools/llvm-ld/llvm-ld.cpp | 16 |
4 files changed, 49 insertions, 20 deletions
diff --git a/llvm/include/llvm/System/Path.h b/llvm/include/llvm/System/Path.h index 8bc8eb8a1e7..306ce84228e 100644 --- a/llvm/include/llvm/System/Path.h +++ b/llvm/include/llvm/System/Path.h @@ -101,7 +101,7 @@ namespace sys { /// @param ErrMsg Optional place for an error message if an error occurs /// @brief Constrct a path to an new, unique, existing temporary /// directory. - static Path GetTemporaryDirectory(std::string* ErrMsg); + static Path GetTemporaryDirectory(std::string* ErrMsg = 0); /// Construct a vector of sys::Path that contains the "standard" system /// library paths suitable for linking into programs. This function *must* @@ -424,18 +424,18 @@ namespace sys { /// This method attempts to make the file referenced by the Path object /// available for reading so that the canRead() method will return true. /// @brief Make the file readable; - void makeReadableOnDisk(); + bool makeReadableOnDisk(std::string* ErrMsg); /// This method attempts to make the file referenced by the Path object /// available for writing so that the canWrite() method will return true. /// @brief Make the file writable; - void makeWriteableOnDisk(); + bool makeWriteableOnDisk(std::string* ErrMsg); /// This method attempts to make the file referenced by the Path object /// available for execution so that the canExecute() method will return /// true. /// @brief Make the file readable; - void makeExecutableOnDisk(); + bool makeExecutableOnDisk(std::string* ErrMsg); /// This method allows the last modified time stamp and permission bits /// to be set on the disk object referenced by the Path. diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc index b1e51b0aff9..db7f4c6fabf 100644 --- a/llvm/lib/System/Unix/Path.inc +++ b/llvm/lib/System/Unix/Path.inc @@ -390,19 +390,28 @@ static bool AddPermissionBits(const Path &File, int bits) { return true; } -void Path::makeReadableOnDisk() { - if (!AddPermissionBits(*this, 0444)) - ThrowErrno(path + ": can't make file readable"); +bool Path::makeReadableOnDisk(std::string* ErrMsg) { + if (!AddPermissionBits(*this, 0444)) { + MakeErrMsg(ErrMsg, path + ": can't make file readable"); + return true; + } + return false; } -void Path::makeWriteableOnDisk() { - if (!AddPermissionBits(*this, 0222)) - ThrowErrno(path + ": can't make file writable"); +bool Path::makeWriteableOnDisk(std::string* ErrMsg) { + if (!AddPermissionBits(*this, 0222)) { + MakeErrMsg(ErrMsg, path + ": can't make file writable"); + return true; + } + return false; } -void Path::makeExecutableOnDisk() { - if (!AddPermissionBits(*this, 0111)) - ThrowErrno(path + ": can't make file executable"); +bool Path::makeExecutableOnDisk(std::string* ErrMsg) { + if (!AddPermissionBits(*this, 0111)) { + MakeErrMsg(ErrMsg, path + ": can't make file executable"); + return true; + } + return false; } bool diff --git a/llvm/tools/gccld/gccld.cpp b/llvm/tools/gccld/gccld.cpp index a9df06d69c7..c8ecde54915 100644 --- a/llvm/tools/gccld/gccld.cpp +++ b/llvm/tools/gccld/gccld.cpp @@ -385,13 +385,23 @@ int main(int argc, char **argv, char **envp ) { EmitShellScript(argv); // Make the bytecode file readable and directly executable in LLEE - sys::Path(RealBytecodeOutput).makeExecutableOnDisk(); - sys::Path(RealBytecodeOutput).makeReadableOnDisk(); + std::string ErrMsg; + if (sys::Path(RealBytecodeOutput).makeExecutableOnDisk(&ErrMsg)) { + std::cerr << argv[0] << ": " << ErrMsg << "\n"; + return 1; + } + if (sys::Path(RealBytecodeOutput).makeReadableOnDisk(&ErrMsg)) { + std::cerr << argv[0] << ": " << ErrMsg << "\n"; + return 1; + } } // Make the output, whether native or script, executable as well... - sys::Path(OutputFilename).makeExecutableOnDisk(); - + std::string ErrMsg; + if (sys::Path(OutputFilename).makeExecutableOnDisk(&ErrMsg)) { + std::cerr << argv[0] << ": " << ErrMsg << "\n"; + return 1; + } } catch (const char*msg) { std::cerr << argv[0] << ": " << msg << "\n"; exitCode = 1; diff --git a/llvm/tools/llvm-ld/llvm-ld.cpp b/llvm/tools/llvm-ld/llvm-ld.cpp index c8e505c9757..679522f63df 100644 --- a/llvm/tools/llvm-ld/llvm-ld.cpp +++ b/llvm/tools/llvm-ld/llvm-ld.cpp @@ -598,11 +598,21 @@ int main(int argc, char **argv, char **envp) { } // Make the script executable... - sys::Path(OutputFilename).makeExecutableOnDisk(); + std::string ErrMsg; + if (sys::Path(OutputFilename).makeExecutableOnDisk(&ErrMsg)) { + std::cerr << argv[0] << ": " << ErrMsg << "\n"; + return 1; + } // Make the bytecode file readable and directly executable in LLEE as well - sys::Path(RealBytecodeOutput).makeExecutableOnDisk(); - sys::Path(RealBytecodeOutput).makeReadableOnDisk(); + if (sys::Path(RealBytecodeOutput).makeExecutableOnDisk(&ErrMsg)) { + std::cerr << argv[0] << ": " << ErrMsg << "\n"; + return 1; + } + if (sys::Path(RealBytecodeOutput).makeReadableOnDisk(&ErrMsg)) { + std::cerr << argv[0] << ": " << ErrMsg << "\n"; + return 1; + } } return 0; |

