[llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp
John Criswell
criswell at cs.uiuc.edu
Tue Sep 2 15:31:02 PDT 2003
Changes in directory llvm/lib/Support:
FileUtilities.cpp updated: 1.4 -> 1.5
---
Log message:
Added a description of the algorithm.
Return failure if the chmod() fails.
---
Diffs of the changes:
Index: llvm/lib/Support/FileUtilities.cpp
diff -u llvm/lib/Support/FileUtilities.cpp:1.4 llvm/lib/Support/FileUtilities.cpp:1.5
--- llvm/lib/Support/FileUtilities.cpp:1.4 Tue Sep 2 15:14:55 2003
+++ llvm/lib/Support/FileUtilities.cpp Tue Sep 2 15:30:16 2003
@@ -98,12 +98,14 @@
///
/// Description:
/// This method makes the specified filename executable by giving it
-/// execute permission.
+/// execute permission. It respects the umask value of the process, and it
+/// does not enable any unnecessary access bits.
///
-/// For the UNIX version of this method, we turn on all of the read and
-/// execute bits and then turn off anything specified in the umask. This
-/// should help ensure that access to the file remains at the level that
-/// the user desires.
+/// Algorithm:
+/// o Get file's current permissions.
+/// o Get the process's current umask.
+/// o Take the set of all execute bits and disable those found in the umask.
+/// o Add the remaining permissions to the file's permissions.
///
bool
MakeFileExecutable (const std::string & Filename)
@@ -134,8 +136,13 @@
return false;
}
- // Make the script executable...
- chmod(Filename.c_str(), (fstat.st_mode | (0111 & ~mask)));
+ //
+ // Make the file executable...
+ //
+ if ((chmod(Filename.c_str(), (fstat.st_mode | (0111 & ~mask)))) == -1)
+ {
+ return false;
+ }
return true;
}
More information about the llvm-commits
mailing list