llvm.org GIT mirror llvm / e1647f4
For PR797: Change the Path::make*OnDisk methods exception free and adjust their usage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29836 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 14 years ago
4 changed file(s) with 53 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
100100 /// @param ErrMsg Optional place for an error message if an error occurs
101101 /// @brief Constrct a path to an new, unique, existing temporary
102102 /// directory.
103 static Path GetTemporaryDirectory(std::string* ErrMsg);
103 static Path GetTemporaryDirectory(std::string* ErrMsg = 0);
104104
105105 /// Construct a vector of sys::Path that contains the "standard" system
106106 /// library paths suitable for linking into programs. This function *must*
423423 /// This method attempts to make the file referenced by the Path object
424424 /// available for reading so that the canRead() method will return true.
425425 /// @brief Make the file readable;
426 void makeReadableOnDisk();
426 bool makeReadableOnDisk(std::string* ErrMsg);
427427
428428 /// This method attempts to make the file referenced by the Path object
429429 /// available for writing so that the canWrite() method will return true.
430430 /// @brief Make the file writable;
431 void makeWriteableOnDisk();
431 bool makeWriteableOnDisk(std::string* ErrMsg);
432432
433433 /// This method attempts to make the file referenced by the Path object
434434 /// available for execution so that the canExecute() method will return
435435 /// true.
436436 /// @brief Make the file readable;
437 void makeExecutableOnDisk();
437 bool makeExecutableOnDisk(std::string* ErrMsg);
438438
439439 /// This method allows the last modified time stamp and permission bits
440440 /// to be set on the disk object referenced by the Path.
389389 return true;
390390 }
391391
392 void Path::makeReadableOnDisk() {
393 if (!AddPermissionBits(*this, 0444))
394 ThrowErrno(path + ": can't make file readable");
395 }
396
397 void Path::makeWriteableOnDisk() {
398 if (!AddPermissionBits(*this, 0222))
399 ThrowErrno(path + ": can't make file writable");
400 }
401
402 void Path::makeExecutableOnDisk() {
403 if (!AddPermissionBits(*this, 0111))
404 ThrowErrno(path + ": can't make file executable");
392 bool Path::makeReadableOnDisk(std::string* ErrMsg) {
393 if (!AddPermissionBits(*this, 0444)) {
394 MakeErrMsg(ErrMsg, path + ": can't make file readable");
395 return true;
396 }
397 return false;
398 }
399
400 bool Path::makeWriteableOnDisk(std::string* ErrMsg) {
401 if (!AddPermissionBits(*this, 0222)) {
402 MakeErrMsg(ErrMsg, path + ": can't make file writable");
403 return true;
404 }
405 return false;
406 }
407
408 bool Path::makeExecutableOnDisk(std::string* ErrMsg) {
409 if (!AddPermissionBits(*this, 0111)) {
410 MakeErrMsg(ErrMsg, path + ": can't make file executable");
411 return true;
412 }
413 return false;
405414 }
406415
407416 bool
384384 EmitShellScript(argv);
385385
386386 // Make the bytecode file readable and directly executable in LLEE
387 sys::Path(RealBytecodeOutput).makeExecutableOnDisk();
388 sys::Path(RealBytecodeOutput).makeReadableOnDisk();
387 std::string ErrMsg;
388 if (sys::Path(RealBytecodeOutput).makeExecutableOnDisk(&ErrMsg)) {
389 std::cerr << argv[0] << ": " << ErrMsg << "\n";
390 return 1;
391 }
392 if (sys::Path(RealBytecodeOutput).makeReadableOnDisk(&ErrMsg)) {
393 std::cerr << argv[0] << ": " << ErrMsg << "\n";
394 return 1;
395 }
389396 }
390397
391398 // Make the output, whether native or script, executable as well...
392 sys::Path(OutputFilename).makeExecutableOnDisk();
393
399 std::string ErrMsg;
400 if (sys::Path(OutputFilename).makeExecutableOnDisk(&ErrMsg)) {
401 std::cerr << argv[0] << ": " << ErrMsg << "\n";
402 return 1;
403 }
394404 } catch (const char*msg) {
395405 std::cerr << argv[0] << ": " << msg << "\n";
396406 exitCode = 1;
597597 }
598598
599599 // Make the script executable...
600 sys::Path(OutputFilename).makeExecutableOnDisk();
600 std::string ErrMsg;
601 if (sys::Path(OutputFilename).makeExecutableOnDisk(&ErrMsg)) {
602 std::cerr << argv[0] << ": " << ErrMsg << "\n";
603 return 1;
604 }
601605
602606 // Make the bytecode file readable and directly executable in LLEE as well
603 sys::Path(RealBytecodeOutput).makeExecutableOnDisk();
604 sys::Path(RealBytecodeOutput).makeReadableOnDisk();
607 if (sys::Path(RealBytecodeOutput).makeExecutableOnDisk(&ErrMsg)) {
608 std::cerr << argv[0] << ": " << ErrMsg << "\n";
609 return 1;
610 }
611 if (sys::Path(RealBytecodeOutput).makeReadableOnDisk(&ErrMsg)) {
612 std::cerr << argv[0] << ": " << ErrMsg << "\n";
613 return 1;
614 }
605615 }
606616
607617 return 0;