mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-11 08:29:25 +00:00
Finegrainify namespacification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10464 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user