diff options
author | Chris Lattner <sabre@nondot.org> | 2003-12-14 21:35:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-12-14 21:35:53 +0000 |
commit | 2cdd21c2e4d855500dfb53f77aa74da53ccf9de6 (patch) | |
tree | 98803f88a663bba4b7955f121b58306f5ae11d85 /lib/Support/FileUtilities.cpp | |
parent | b6d465f8131f5fb0b8e565685fb3395ed9aecbdb (diff) |
Finegrainify namespacification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/FileUtilities.cpp')
-rw-r--r-- | lib/Support/FileUtilities.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 4e3c22ce7c..e6abc8fb40 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -19,14 +19,12 @@ #include <fstream> #include <iostream> #include <cstdio> - -namespace llvm -{ +using namespace llvm; /// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must /// name a readable file. /// -bool CheckMagic (const std::string &FN, const std::string &Magic) { +bool llvm::CheckMagic(const std::string &FN, const std::string &Magic) { char buf[1 + Magic.size ()]; std::ifstream f (FN.c_str ()); f.read (buf, Magic.size ()); @@ -37,7 +35,7 @@ bool CheckMagic (const std::string &FN, const std::string &Magic) { /// IsArchive - Returns true IFF the file named FN appears to be a "ar" library /// archive. The file named FN must exist. /// -bool IsArchive(const std::string &FN) { +bool llvm::IsArchive(const std::string &FN) { // Inspect the beginning of the file to see if it contains the "ar" // library archive format magic string. return CheckMagic (FN, "!<arch>\012"); @@ -46,7 +44,7 @@ bool IsArchive(const std::string &FN) { /// IsBytecode - Returns true IFF the file named FN appears to be an LLVM /// bytecode file. The file named FN must exist. /// -bool IsBytecode(const std::string &FN) { +bool llvm::IsBytecode(const std::string &FN) { // Inspect the beginning of the file to see if it contains the LLVM // bytecode format magic string. return CheckMagic (FN, "llvm"); @@ -55,7 +53,7 @@ bool IsBytecode(const std::string &FN) { /// IsSharedObject - Returns trus IFF the file named FN appears to be a shared /// object with an ELF header. The file named FN must exist. /// -bool IsSharedObject(const std::string &FN) { +bool llvm::IsSharedObject(const std::string &FN) { // Inspect the beginning of the file to see if it contains the ELF shared // object magic string. static const char elfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' }; @@ -65,7 +63,7 @@ bool IsSharedObject(const std::string &FN) { /// FileOpenable - Returns true IFF Filename names an existing regular /// file which we can successfully open. /// -bool FileOpenable (const std::string &Filename) { +bool llvm::FileOpenable(const std::string &Filename) { struct stat s; if (stat (Filename.c_str (), &s) == -1) return false; // Cannot stat file @@ -83,8 +81,8 @@ bool FileOpenable (const std::string &Filename) { /// occurs, allowing the caller to distinguish between a failed diff and a file /// system error. /// -bool DiffFiles(const std::string &FileA, const std::string &FileB, - std::string *Error) { +bool llvm::DiffFiles(const std::string &FileA, const std::string &FileB, + std::string *Error) { std::ifstream FileAStream(FileA.c_str()); if (!FileAStream) { if (Error) *Error = "Couldn't open file '" + FileA + "'"; @@ -113,7 +111,8 @@ bool DiffFiles(const std::string &FileA, const std::string &FileB, /// or if Old does not exist, move the New file over the Old file. Otherwise, /// remove the New file. /// -void MoveFileOverIfUpdated(const std::string &New, const std::string &Old) { +void llvm::MoveFileOverIfUpdated(const std::string &New, + const std::string &Old) { if (DiffFiles(New, Old)) { if (std::rename(New.c_str(), Old.c_str())) std::cerr << "Error renaming '" << New << "' to '" << Old << "'!\n"; @@ -124,7 +123,7 @@ void MoveFileOverIfUpdated(const std::string &New, const std::string &Old) { /// removeFile - Delete the specified file /// -void removeFile(const std::string &Filename) { +void llvm::removeFile(const std::string &Filename) { std::remove(Filename.c_str()); } @@ -132,7 +131,7 @@ void removeFile(const std::string &Filename) { /// file does not exist yet, return it, otherwise add a suffix to make it /// unique. /// -std::string getUniqueFilename(const std::string &FilenameBase) { +std::string llvm::getUniqueFilename(const std::string &FilenameBase) { if (!std::ifstream(FilenameBase.c_str())) return FilenameBase; // Couldn't open the file? Use it! @@ -183,8 +182,8 @@ static bool AddPermissionsBits (const std::string &Filename, mode_t bits) { /// umask would allow. Filename must name an existing file or /// directory. Returns true on success, false on error. /// -bool MakeFileExecutable (const std::string &Filename) { - return AddPermissionsBits (Filename, 0111); +bool llvm::MakeFileExecutable(const std::string &Filename) { + return AddPermissionsBits(Filename, 0111); } /// MakeFileReadable - Make the file named Filename readable by @@ -192,8 +191,6 @@ bool MakeFileExecutable (const std::string &Filename) { /// umask would allow. Filename must name an existing file or /// directory. Returns true on success, false on error. /// -bool MakeFileReadable (const std::string &Filename) { - return AddPermissionsBits (Filename, 0444); +bool llvm::MakeFileReadable(const std::string &Filename) { + return AddPermissionsBits(Filename, 0444); } - -} // End llvm namespace |