mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
For PR495:
Get rid of the difference between file paths and directory paths. The Path class now simply stores a path that can refer to either a file or a directory. This required various changes in the implementation and interface of the class with the corresponding impact to its users. Doxygen comments were also updated to reflect these changes. Interface changes are: appendDirectory -> appendComponent appendFile -> appendComponent elideDirectory -> eraseComponent elideFile -> eraseComponent elideSuffix -> eraseSuffix renameFile -> rename setDirectory -> set setFile -> set Changes pass Dejagnu and llvm-test/SingleSource tests. llvm-svn: 22349
This commit is contained in:
parent
e102466ece
commit
5534b2d505
@ -45,7 +45,7 @@ namespace llvm {
|
||||
~FileRemover() {
|
||||
if (DeleteIt)
|
||||
try {
|
||||
Filename.destroyFile();
|
||||
Filename.destroy();
|
||||
} catch (...) {} // Ignore problems deleting the file.
|
||||
}
|
||||
|
||||
|
@ -219,24 +219,22 @@ namespace sys {
|
||||
bool isValid() const;
|
||||
|
||||
/// This function determines if the contents of the path name are
|
||||
/// empty. That is, the path has a zero length.
|
||||
/// empty. That is, the path has a zero length. This does NOT determine if
|
||||
/// if the file is empty. Use the getSize method for that.
|
||||
/// @returns true iff the path is empty.
|
||||
/// @brief Determines if the path name is empty (invalid).
|
||||
bool isEmpty() const { return path.empty(); }
|
||||
|
||||
/// This function determines if the path name in this object is intended
|
||||
/// to reference a legal file name (as opposed to a directory name). This
|
||||
/// function does not verify anything with the file system, it merely
|
||||
/// determines if the syntax of the path represents a file name or not.
|
||||
/// This function determines if the object referenced by this path is
|
||||
/// a file or not. This function accesses the under lying file system to
|
||||
/// determine the type of entity referenced by the path.
|
||||
/// @returns true if this path name references a file.
|
||||
/// @brief Determines if the path name references a file.
|
||||
bool isFile() const;
|
||||
|
||||
/// This function determines if the path name in this object is intended
|
||||
/// to reference a legal directory name (as opposed to a file name). This
|
||||
/// function does not verify anything with the file system, it merely
|
||||
/// determines if the syntax of the path represents a directory name or
|
||||
/// not.
|
||||
/// This function determines if the object referenced by this path is a
|
||||
/// directory or not. This function accesses the underlying file system to
|
||||
/// determine the type of entity referenced by the path.
|
||||
/// @returns true if the path name references a directory
|
||||
/// @brief Determines if the path name references a directory.
|
||||
bool isDirectory() const;
|
||||
@ -297,35 +295,34 @@ namespace sys {
|
||||
bool isDynamicLibrary() const;
|
||||
|
||||
/// This function determines if the path name references an existing file
|
||||
/// or directory in the file system. Unlike isFile and isDirectory, this
|
||||
/// function actually checks for the existence of the file or directory.
|
||||
/// @returns true if the pathname references an existing file.
|
||||
/// or directory in the file system.
|
||||
/// @returns true if the pathname references an existing file or
|
||||
/// directory.
|
||||
/// @brief Determines if the path is a file or directory in
|
||||
/// the file system.
|
||||
bool exists() const;
|
||||
|
||||
/// This function determines if the path name references a readable file
|
||||
/// or directory in the file system. Unlike isFile and isDirectory, this
|
||||
/// function actually checks for the existence and readability (by the
|
||||
/// current program) of the file or directory.
|
||||
/// or directory in the file system. This function checks for
|
||||
/// the existence and readability (by the current program) of the file
|
||||
/// or directory.
|
||||
/// @returns true if the pathname references a readable file.
|
||||
/// @brief Determines if the path is a readable file or directory
|
||||
/// in the file system.
|
||||
bool canRead() const;
|
||||
|
||||
/// This function determines if the path name references a writable file
|
||||
/// or directory in the file system. Unlike isFile and isDirectory, this
|
||||
/// function actually checks for the existence and writability (by the
|
||||
/// current program) of the file or directory.
|
||||
/// or directory in the file system. This function checks for the
|
||||
/// existence and writability (by the current program) of the file or
|
||||
/// directory.
|
||||
/// @returns true if the pathname references a writable file.
|
||||
/// @brief Determines if the path is a writable file or directory
|
||||
/// in the file system.
|
||||
bool canWrite() const;
|
||||
|
||||
/// This function determines if the path name references an executable
|
||||
/// file in the file system. Unlike isFile and isDirectory, this
|
||||
/// function actually checks for the existence and executability (by
|
||||
/// the current program) of the file.
|
||||
/// file in the file system. This function checks for the existence and
|
||||
/// executability (by the current program) of the file.
|
||||
/// @returns true if the pathname references an executable file.
|
||||
/// @brief Determines if the path is an executable file in the file
|
||||
/// system.
|
||||
@ -338,17 +335,16 @@ namespace sys {
|
||||
/// @brief Returns the path as a std::string.
|
||||
const std::string& toString() const { return path; }
|
||||
|
||||
/// This function returns the last component of the path name. If the
|
||||
/// isDirectory() function would return true then this returns the name
|
||||
/// of the last directory in the path. If the isFile() function would
|
||||
/// return true then this function returns the name of the file without
|
||||
/// any of the preceding directories.
|
||||
/// This function returns the last component of the path name. The last
|
||||
/// component is the file or directory name occuring after the last
|
||||
/// directory separator.
|
||||
/// @returns std::string containing the last component of the path name.
|
||||
/// @brief Returns the last component of the path name.
|
||||
std::string getLast() const;
|
||||
|
||||
/// This function strips off the path and suffix of the file name and
|
||||
/// returns just the basename.
|
||||
/// This function strips off the path and suffix of the file or directory
|
||||
/// name and returns just the basename. For example /a/foo.bar would cause
|
||||
/// this function to return "foo".
|
||||
/// @returns std::string containing the basename of the path
|
||||
/// @throws nothing
|
||||
/// @brief Get the base name of the path
|
||||
@ -361,26 +357,20 @@ namespace sys {
|
||||
/// @brief Build a list of directory's contents.
|
||||
bool getDirectoryContents(std::set<Path>& paths) const;
|
||||
|
||||
/// This method attempts to destroy the directory named by the last in
|
||||
/// the Path name. If \p remove_contents is false, an attempt will be
|
||||
/// made to remove just the directory that this Path object refers to
|
||||
/// (the final Path component). If \p remove_contents is true, an attempt
|
||||
/// will be made to remove the entire contents of the directory,
|
||||
/// recursively.
|
||||
/// This method attempts to destroy the file or directory named by the
|
||||
/// last component of the Path. If the Path refers to a directory and the
|
||||
/// \p destroy_contents is false, an attempt will be made to remove just
|
||||
/// the directory (the final Path component). If \p destroy_contents is
|
||||
/// true, an attempt will be made to remove the entire contents of the
|
||||
/// directory, recursively. If the Path refers to a file, the
|
||||
/// \p destroy_contents parameter is ignored.
|
||||
/// @param destroy_contents Indicates whether the contents of a destroyed
|
||||
/// directory should also be destroyed (recursively).
|
||||
/// @returns false if the Path does not refer to a directory, true
|
||||
/// otherwise.
|
||||
/// @returns true if the file/directory was destroyed, false if the path
|
||||
/// refers to something that is neither a file nor a directory.
|
||||
/// @throws std::string if there is an error.
|
||||
/// @brief Removes the file or directory from the filesystem.
|
||||
bool destroyDirectory( bool destroy_contents = false ) const;
|
||||
|
||||
/// This method attempts to destroy the file named by the last item in the
|
||||
/// Path name.
|
||||
/// @returns false if the Path does not refer to a file, true otherwise.
|
||||
/// @throws std::string if there is an error.
|
||||
/// @brief Destroy the file this Path refers to.
|
||||
bool destroyFile() const;
|
||||
bool destroy( bool destroy_contents = false ) const;
|
||||
|
||||
/// Obtain a 'C' string for the path name.
|
||||
/// @returns a 'C' string containing the path name.
|
||||
@ -437,64 +427,32 @@ namespace sys {
|
||||
/// @brief Make the file readable;
|
||||
void makeExecutable();
|
||||
|
||||
/// This method attempts to set the Path object to \p unverified_path
|
||||
/// and interpret the name as a directory name. The \p unverified_path
|
||||
/// is verified. If verification succeeds then \p unverified_path
|
||||
/// is accepted as a directory and true is returned. Otherwise,
|
||||
/// the Path object remains unchanged and false is returned.
|
||||
/// This method sets the Path object to \p unverified_path. This can fail
|
||||
/// if the \p unverified_path does not pass the syntactic checks of the
|
||||
/// isValid method. If verification fails, the Path object remains
|
||||
/// unchanged and false is returned. Otherwise true is returned and the
|
||||
/// Path object takes on the path value of \p unverified_path
|
||||
/// @returns true if the path was set, false otherwise.
|
||||
/// @param unverified_path The path to be set in Path object.
|
||||
/// @throws nothing
|
||||
/// @brief Set a full path from a std::string
|
||||
bool setDirectory(const std::string& unverified_path);
|
||||
bool set(const std::string& unverified_path);
|
||||
|
||||
/// This method attempts to set the Path object to \p unverified_path
|
||||
/// and interpret the name as a file name. The \p unverified_path
|
||||
/// is verified. If verification succeeds then \p unverified_path
|
||||
/// is accepted as a file name and true is returned. Otherwise,
|
||||
/// the Path object remains unchanged and false is returned.
|
||||
/// @returns true if the path was set, false otherwise.
|
||||
/// @param unverified_path The path to be set in Path object.
|
||||
/// One path component is removed from the Path. If only one component is
|
||||
/// present in the path, the Path object becomes empty. If the Path object
|
||||
/// is empty, no change is made.
|
||||
/// @throws nothing
|
||||
/// @brief Set a full path from a std::string
|
||||
bool setFile(const std::string& unverified_path);
|
||||
|
||||
/// The \p dirname is added to the end of the Path if it is a legal
|
||||
/// directory name for the operating system. The precondition for this
|
||||
/// function is that the Path must reference a directory name (i.e.
|
||||
/// isDirectory() returns true).
|
||||
/// @param dirname A string providing the directory name to
|
||||
/// be added to the end of the path.
|
||||
/// @returns false if the directory name could not be added
|
||||
/// @throws nothing
|
||||
/// @brief Adds the name of a directory to a Path.
|
||||
bool appendDirectory( const std::string& dirname );
|
||||
|
||||
/// One directory component is removed from the Path name. The Path must
|
||||
/// refer to a non-root directory name (i.e. isDirectory() returns true
|
||||
/// but isRootDirectory() returns false). Upon exit, the Path will
|
||||
/// refer to the directory above it.
|
||||
/// @throws nothing
|
||||
/// @returns false if the directory name could not be removed.
|
||||
/// @returns false if the path component could not be removed.
|
||||
/// @brief Removes the last directory component of the Path.
|
||||
bool elideDirectory();
|
||||
bool eraseComponent();
|
||||
|
||||
/// The \p filename is added to the end of the Path if it is a legal
|
||||
/// directory name for the operating system. The precondition for this
|
||||
/// function is that the Path reference a directory name (i.e.
|
||||
/// isDirectory() returns true).
|
||||
/// The \p component is added to the end of the Path if it is a legal
|
||||
/// name for the operating system. A directory separator will be added if
|
||||
/// needed.
|
||||
/// @throws nothing
|
||||
/// @returns false if the file name could not be added.
|
||||
/// @brief Appends the name of a file.
|
||||
bool appendFile( const std::string& filename );
|
||||
|
||||
/// One file component is removed from the Path name. The Path must
|
||||
/// refer to a file (i.e. isFile() returns true). Upon exit,
|
||||
/// the Path will refer to the directory above it.
|
||||
/// @throws nothing
|
||||
/// @returns false if the file name could not be removed
|
||||
/// @brief Removes the last file component of the path.
|
||||
bool elideFile();
|
||||
/// @returns false if the path component could not be added.
|
||||
/// @brief Appends one path component to the Path.
|
||||
bool appendComponent( const std::string& component );
|
||||
|
||||
/// A period and the \p suffix are appended to the end of the pathname.
|
||||
/// The precondition for this function is that the Path reference a file
|
||||
@ -506,7 +464,7 @@ namespace sys {
|
||||
/// @brief Adds a period and the \p suffix to the end of the pathname.
|
||||
bool appendSuffix(const std::string& suffix);
|
||||
|
||||
/// The suffix of the filename is removed. The suffix begins with and
|
||||
/// The suffix of the filename is erased. The suffix begins with and
|
||||
/// includes the last . character in the filename after the last directory
|
||||
/// separator and extends until the end of the name. If no . character is
|
||||
/// after the last directory separator, then the file name is left
|
||||
@ -515,7 +473,7 @@ namespace sys {
|
||||
/// @returns false if there was no suffix to remove, true otherwise.
|
||||
/// @throws nothing
|
||||
/// @brief Remove the suffix from a path name.
|
||||
bool elideSuffix();
|
||||
bool eraseSuffix();
|
||||
|
||||
/// The current Path name is made unique in the file system. Upon return,
|
||||
/// the Path will have been changed to make a unique file in the file
|
||||
@ -566,7 +524,7 @@ namespace sys {
|
||||
/// @returns false if the Path does not refer to a file, true otherwise.
|
||||
/// @throws std::string if there is an file system error.
|
||||
/// @brief Rename one file as another.
|
||||
bool renameFile(const Path& newName);
|
||||
bool rename(const Path& newName);
|
||||
|
||||
/// This method sets the access time, modification time, and permission
|
||||
/// mode of the file associated with \p this as given by \p si.
|
||||
|
@ -187,7 +187,7 @@ Archive::parseMemberHeader(const char*& At, const char* End) {
|
||||
member->next = 0;
|
||||
member->prev = 0;
|
||||
member->parent = this;
|
||||
member->path.setFile(pathname);
|
||||
member->path.set(pathname);
|
||||
member->info.fileSize = MemberSize;
|
||||
member->info.modTime.fromEpochTime(atoi(Hdr->date));
|
||||
unsigned int mode;
|
||||
|
@ -450,17 +450,17 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){
|
||||
// Close up shop
|
||||
FinalFile.close();
|
||||
arch.close();
|
||||
TmpArchive.destroyFile();
|
||||
TmpArchive.destroy();
|
||||
|
||||
} else {
|
||||
// We don't have to insert the symbol table, so just renaming the temp
|
||||
// file to the correct name will suffice.
|
||||
TmpArchive.renameFile(archPath);
|
||||
TmpArchive.rename(archPath);
|
||||
}
|
||||
} catch (...) {
|
||||
// Make sure we clean up.
|
||||
if (TmpArchive.exists())
|
||||
TmpArchive.destroyFile();
|
||||
TmpArchive.destroy();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -172,8 +172,8 @@ SourceFile &SourceFileInfo::getSourceText() const {
|
||||
if (SourceText == 0) { // Read the file in if we haven't already.
|
||||
sys::Path tmpPath;
|
||||
if (!Directory.empty())
|
||||
tmpPath.setDirectory(Directory);
|
||||
tmpPath.appendFile(BaseName);
|
||||
tmpPath.set(Directory);
|
||||
tmpPath.appendComponent(BaseName);
|
||||
if (tmpPath.canRead())
|
||||
SourceText = new SourceFile(tmpPath.toString(), Descriptor);
|
||||
else
|
||||
|
@ -899,7 +899,7 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
|
||||
// If the source library's module id is in the dependent library list of the
|
||||
// destination library, remove it since that module is now linked in.
|
||||
sys::Path modId;
|
||||
modId.setFile(Src->getModuleIdentifier());
|
||||
modId.set(Src->getModuleIdentifier());
|
||||
if (!modId.isEmpty())
|
||||
Dest->removeLibrary(modId.getBasename());
|
||||
|
||||
|
@ -69,7 +69,6 @@ Linker::verbose(const std::string& message) {
|
||||
|
||||
void
|
||||
Linker::addPath(const sys::Path& path) {
|
||||
assert(path.isDirectory() && "Can only insert directories into the path");
|
||||
LibPaths.push_back(path);
|
||||
}
|
||||
|
||||
@ -77,7 +76,7 @@ void
|
||||
Linker::addPaths(const std::vector<std::string>& paths) {
|
||||
for (unsigned i = 0; i != paths.size(); ++i) {
|
||||
sys::Path aPath;
|
||||
aPath.setDirectory(paths[i]);
|
||||
aPath.set(paths[i]);
|
||||
LibPaths.push_back(aPath);
|
||||
}
|
||||
}
|
||||
@ -118,26 +117,35 @@ Linker::LoadObject(const sys::Path &FN) {
|
||||
static inline sys::Path IsLibrary(const std::string& Name,
|
||||
const sys::Path& Directory) {
|
||||
|
||||
assert(Directory.isDirectory() && "Need to specify a directory");
|
||||
sys::Path FullPath(Directory);
|
||||
FullPath.appendFile("lib" + Name);
|
||||
|
||||
FullPath.appendSuffix("a");
|
||||
if (FullPath.isArchive())
|
||||
return FullPath;
|
||||
// Make sure the directory actually is a directory in the file system.
|
||||
if (FullPath.isDirectory())
|
||||
{
|
||||
// Try the libX.a form
|
||||
FullPath.appendComponent("lib" + Name);
|
||||
FullPath.appendSuffix("a");
|
||||
if (FullPath.isArchive())
|
||||
return FullPath;
|
||||
|
||||
FullPath.elideSuffix();
|
||||
FullPath.appendSuffix("bca");
|
||||
if (FullPath.isArchive())
|
||||
return FullPath;
|
||||
// Try the libX.bca form
|
||||
FullPath.eraseSuffix();
|
||||
FullPath.appendSuffix("bca");
|
||||
if (FullPath.isArchive())
|
||||
return FullPath;
|
||||
|
||||
FullPath.elideSuffix();
|
||||
FullPath.appendSuffix(&(LTDL_SHLIB_EXT[1]));
|
||||
if (FullPath.isDynamicLibrary()) // Native shared library?
|
||||
return FullPath;
|
||||
if (FullPath.isBytecodeFile()) // .so file containing bytecode?
|
||||
return FullPath;
|
||||
// Try the libX.so form
|
||||
FullPath.eraseSuffix();
|
||||
FullPath.appendSuffix(&(LTDL_SHLIB_EXT[1]));
|
||||
if (FullPath.isDynamicLibrary()) // Native shared library?
|
||||
return FullPath;
|
||||
if (FullPath.isBytecodeFile()) // .so file containing bytecode?
|
||||
return FullPath;
|
||||
|
||||
// Not found .. fall through
|
||||
}
|
||||
|
||||
// Indicate that the library was not found in the directory.
|
||||
FullPath.clear();
|
||||
return FullPath;
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ sys::Path llvm::FindExecutable(const std::string &ExeName,
|
||||
// if ProgramPath contains at least one / character, indicating that it is a
|
||||
// relative path to bugpoint itself.
|
||||
sys::Path Result ( ProgramPath );
|
||||
Result.elideFile();
|
||||
Result.eraseComponent();
|
||||
if (!Result.isEmpty()) {
|
||||
Result.appendFile(ExeName);
|
||||
Result.appendComponent(ExeName);
|
||||
if (Result.canExecute())
|
||||
return Result;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ static void ProcessFailure(sys::Path ProgPath, const char** Args) {
|
||||
ErrorFile.close();
|
||||
}
|
||||
|
||||
ErrorFilename.destroyFile();
|
||||
ErrorFilename.destroy();
|
||||
throw ToolExecutionError(OS.str());
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ void LLC::OutputAsm(const std::string &Bytecode, sys::Path &OutputAsmFile) {
|
||||
void LLC::compileProgram(const std::string &Bytecode) {
|
||||
sys::Path OutputAsmFile;
|
||||
OutputAsm(Bytecode, OutputAsmFile);
|
||||
OutputAsmFile.destroyFile();
|
||||
OutputAsmFile.destroy();
|
||||
}
|
||||
|
||||
int LLC::ExecuteProgram(const std::string &Bytecode,
|
||||
@ -321,7 +321,7 @@ void CBE::OutputC(const std::string &Bytecode, sys::Path& OutputCFile) {
|
||||
void CBE::compileProgram(const std::string &Bytecode) {
|
||||
sys::Path OutputCFile;
|
||||
OutputC(Bytecode, OutputCFile);
|
||||
OutputCFile.destroyFile();
|
||||
OutputCFile.destroy();
|
||||
}
|
||||
|
||||
int CBE::ExecuteProgram(const std::string &Bytecode,
|
||||
|
@ -27,7 +27,7 @@ Path
|
||||
Path::GetLLVMConfigDir() {
|
||||
Path result;
|
||||
#ifdef LLVM_ETCDIR
|
||||
if (result.setDirectory(LLVM_ETCDIR))
|
||||
if (result.set(LLVM_ETCDIR))
|
||||
return result;
|
||||
#endif
|
||||
return GetLLVMDefaultConfigDir();
|
||||
@ -80,10 +80,10 @@ Path::FindLibrary(std::string& name) {
|
||||
GetSystemLibraryPaths(LibPaths);
|
||||
for (unsigned i = 0; i < LibPaths.size(); ++i) {
|
||||
sys::Path FullPath(LibPaths[i]);
|
||||
FullPath.appendFile("lib" + name + LTDL_SHLIB_EXT);
|
||||
FullPath.appendComponent("lib" + name + LTDL_SHLIB_EXT);
|
||||
if (FullPath.isDynamicLibrary())
|
||||
return FullPath;
|
||||
FullPath.elideSuffix();
|
||||
FullPath.eraseSuffix();
|
||||
FullPath.appendSuffix("a");
|
||||
if (FullPath.isArchive())
|
||||
return FullPath;
|
||||
|
@ -84,7 +84,7 @@ Path::isValid() const {
|
||||
Path
|
||||
Path::GetRootDirectory() {
|
||||
Path result;
|
||||
result.setDirectory("/");
|
||||
result.set("/");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ Path::GetTemporaryDirectory() {
|
||||
if (0 == mkdtemp(pathname))
|
||||
ThrowErrno(std::string(pathname) + ": can't create temporary directory");
|
||||
Path result;
|
||||
result.setDirectory(pathname);
|
||||
result.set(pathname);
|
||||
assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
|
||||
return result;
|
||||
#elif defined(HAVE_MKSTEMP)
|
||||
@ -117,7 +117,7 @@ Path::GetTemporaryDirectory() {
|
||||
if (-1 == ::mkdir(pathname, S_IRWXU)) // end race condition
|
||||
ThrowErrno(std::string(pathname) + ": can't create temporary directory");
|
||||
Path result;
|
||||
result.setDirectory(pathname);
|
||||
result.set(pathname);
|
||||
assert(result.isValid() && "mkstemp didn't create a valid pathname!");
|
||||
return result;
|
||||
#elif defined(HAVE_MKTEMP)
|
||||
@ -134,7 +134,7 @@ Path::GetTemporaryDirectory() {
|
||||
if (-1 == ::mkdir(TmpName, S_IRWXU))
|
||||
ThrowErrno(std::string(TmpName) + ": can't create temporary directory");
|
||||
Path result;
|
||||
result.setDirectory(TmpName);
|
||||
result.set(TmpName);
|
||||
assert(result.isValid() && "mktemp didn't create a valid pathname!");
|
||||
return result;
|
||||
#else
|
||||
@ -155,7 +155,7 @@ Path::GetTemporaryDirectory() {
|
||||
if (-1 == ::mkdir(pathname, S_IRWXU))
|
||||
ThrowErrno(std::string(pathname) + ": can't create temporary directory");
|
||||
Path result;
|
||||
result.setDirectory(pathname);
|
||||
result.set(pathname);
|
||||
assert(result.isValid() && "mkstemp didn't create a valid pathname!");
|
||||
return result;
|
||||
#endif
|
||||
@ -167,14 +167,14 @@ static void getPathList(const char*path, std::vector<sys::Path>& Paths) {
|
||||
Path tmpPath;
|
||||
while( delim != 0 ) {
|
||||
std::string tmp(at, size_t(delim-at));
|
||||
if (tmpPath.setDirectory(tmp))
|
||||
if (tmpPath.set(tmp))
|
||||
if (tmpPath.canRead())
|
||||
Paths.push_back(tmpPath);
|
||||
at = delim + 1;
|
||||
delim = strchr(at, ':');
|
||||
}
|
||||
if (*at != 0)
|
||||
if (tmpPath.setDirectory(std::string(at)))
|
||||
if (tmpPath.set(std::string(at)))
|
||||
if (tmpPath.canRead())
|
||||
Paths.push_back(tmpPath);
|
||||
|
||||
@ -204,7 +204,7 @@ Path::GetBytecodeLibraryPaths(std::vector<sys::Path>& Paths) {
|
||||
#ifdef LLVM_LIBDIR
|
||||
{
|
||||
Path tmpPath;
|
||||
if (tmpPath.setDirectory(LLVM_LIBDIR))
|
||||
if (tmpPath.set(LLVM_LIBDIR))
|
||||
if (tmpPath.canRead())
|
||||
Paths.push_back(tmpPath);
|
||||
}
|
||||
@ -222,7 +222,7 @@ Path::GetUserHomeDirectory() {
|
||||
const char* home = getenv("HOME");
|
||||
if (home) {
|
||||
Path result;
|
||||
if (result.setDirectory(home))
|
||||
if (result.set(home))
|
||||
return result;
|
||||
}
|
||||
return GetRootDirectory();
|
||||
@ -230,12 +230,20 @@ Path::GetUserHomeDirectory() {
|
||||
|
||||
bool
|
||||
Path::isFile() const {
|
||||
return (isValid() && path[path.length()-1] != '/');
|
||||
struct stat buf;
|
||||
if (0 != stat(path.c_str(), &buf)) {
|
||||
ThrowErrno(path + ": can't determine type of path object: ");
|
||||
}
|
||||
return S_ISREG(buf.st_mode);
|
||||
}
|
||||
|
||||
bool
|
||||
Path::isDirectory() const {
|
||||
return (isValid() && path[path.length()-1] == '/');
|
||||
struct stat buf;
|
||||
if (0 != stat(path.c_str(), &buf)) {
|
||||
ThrowErrno(path + ": can't determine type of path object: ");
|
||||
}
|
||||
return S_ISDIR(buf.st_mode);
|
||||
}
|
||||
|
||||
std::string
|
||||
@ -357,8 +365,6 @@ Path::getStatusInfo(StatusInfo& info) const {
|
||||
info.user = buf.st_uid;
|
||||
info.group = buf.st_gid;
|
||||
info.isDir = S_ISDIR(buf.st_mode);
|
||||
if (info.isDir && path[path.length()-1] != '/')
|
||||
path += '/';
|
||||
}
|
||||
|
||||
static bool AddPermissionBits(const std::string& Filename, int bits) {
|
||||
@ -419,8 +425,6 @@ Path::getDirectoryContents(std::set<Path>& result) const {
|
||||
ThrowErrno(aPath.path +
|
||||
": can't determine file object type", stat_errno);
|
||||
}
|
||||
if (S_ISDIR(buf.st_mode))
|
||||
aPath.path += "/";
|
||||
result.insert(aPath);
|
||||
}
|
||||
}
|
||||
@ -430,124 +434,84 @@ Path::getDirectoryContents(std::set<Path>& result) const {
|
||||
}
|
||||
|
||||
bool
|
||||
Path::setDirectory(const std::string& a_path) {
|
||||
if (a_path.size() == 0)
|
||||
Path::set(const std::string& a_path) {
|
||||
if (a_path.empty())
|
||||
return false;
|
||||
Path save(*this);
|
||||
std::string save(path);
|
||||
path = a_path;
|
||||
size_t last = a_path.size() -1;
|
||||
if (a_path[last] != '/')
|
||||
path += '/';
|
||||
if (!isValid()) {
|
||||
path = save.path;
|
||||
path = save;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::setFile(const std::string& a_path) {
|
||||
if (a_path.size() == 0)
|
||||
Path::appendComponent(const std::string& name) {
|
||||
if (name.empty())
|
||||
return false;
|
||||
Path save(*this);
|
||||
path = a_path;
|
||||
size_t last = a_path.size() - 1;
|
||||
while (last > 0 && a_path[last] == '/')
|
||||
last--;
|
||||
path.erase(last+1);
|
||||
std::string save(path);
|
||||
if (!path.empty()) {
|
||||
size_t last = path.size() - 1;
|
||||
if (path[last] != '/')
|
||||
path += '/';
|
||||
}
|
||||
path += name;
|
||||
if (!isValid()) {
|
||||
path = save.path;
|
||||
path = save;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::appendDirectory(const std::string& dir) {
|
||||
if (isFile())
|
||||
return false;
|
||||
Path save(*this);
|
||||
path += dir;
|
||||
path += "/";
|
||||
if (!isValid()) {
|
||||
path = save.path;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::elideDirectory() {
|
||||
if (isFile())
|
||||
return false;
|
||||
Path::eraseComponent() {
|
||||
size_t slashpos = path.rfind('/',path.size());
|
||||
if (slashpos == 0 || slashpos == std::string::npos)
|
||||
return false;
|
||||
if (slashpos == 0 || slashpos == std::string::npos) {
|
||||
path.erase();
|
||||
return true;
|
||||
}
|
||||
if (slashpos == path.size() - 1)
|
||||
slashpos = path.rfind('/',slashpos-1);
|
||||
if (slashpos == std::string::npos)
|
||||
return false;
|
||||
if (slashpos == std::string::npos) {
|
||||
path.erase();
|
||||
return true;
|
||||
}
|
||||
path.erase(slashpos);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::appendFile(const std::string& file) {
|
||||
if (!isDirectory())
|
||||
return false;
|
||||
Path save(*this);
|
||||
path += file;
|
||||
if (!isValid()) {
|
||||
path = save.path;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::elideFile() {
|
||||
if (isDirectory())
|
||||
return false;
|
||||
size_t slashpos = path.rfind('/',path.size());
|
||||
if (slashpos == std::string::npos)
|
||||
return false;
|
||||
path.erase(slashpos+1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::appendSuffix(const std::string& suffix) {
|
||||
if (isDirectory())
|
||||
return false;
|
||||
Path save(*this);
|
||||
std::string save(path);
|
||||
path.append(".");
|
||||
path.append(suffix);
|
||||
if (!isValid()) {
|
||||
path = save.path;
|
||||
path = save;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::elideSuffix() {
|
||||
if (isDirectory()) return false;
|
||||
bool
|
||||
Path::eraseSuffix() {
|
||||
std::string save(path);
|
||||
size_t dotpos = path.rfind('.',path.size());
|
||||
size_t slashpos = path.rfind('/',path.size());
|
||||
if (slashpos != std::string::npos && dotpos != std::string::npos &&
|
||||
if (slashpos != std::string::npos &&
|
||||
dotpos != std::string::npos &&
|
||||
dotpos > slashpos) {
|
||||
path.erase(dotpos, path.size()-dotpos);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (!isValid()) {
|
||||
path = save;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Path::createDirectory( bool create_parents) {
|
||||
// Make sure we're dealing with a directory
|
||||
if (!isDirectory()) return false;
|
||||
|
||||
// Get a writeable copy of the path name
|
||||
char pathname[MAXPATHLEN];
|
||||
path.copy(pathname,MAXPATHLEN);
|
||||
@ -586,9 +550,6 @@ Path::createDirectory( bool create_parents) {
|
||||
|
||||
bool
|
||||
Path::createFile() {
|
||||
// Make sure we're dealing with a file
|
||||
if (!isFile()) return false;
|
||||
|
||||
// Create the file
|
||||
int fd = ::creat(path.c_str(), S_IRUSR | S_IWUSR);
|
||||
if (fd < 0)
|
||||
@ -600,10 +561,6 @@ Path::createFile() {
|
||||
|
||||
bool
|
||||
Path::createTemporaryFile(bool reuse_current) {
|
||||
// Make sure we're dealing with a file
|
||||
if (!isFile())
|
||||
return false;
|
||||
|
||||
// Make this into a unique file name
|
||||
makeUnique( reuse_current );
|
||||
|
||||
@ -617,45 +574,38 @@ Path::createTemporaryFile(bool reuse_current) {
|
||||
}
|
||||
|
||||
bool
|
||||
Path::destroyDirectory(bool remove_contents) const {
|
||||
Path::destroy(bool remove_contents) const {
|
||||
// Make sure we're dealing with a directory
|
||||
if (!isDirectory()) return false;
|
||||
|
||||
// If it doesn't exist, we're done.
|
||||
if (!exists()) return true;
|
||||
|
||||
if (remove_contents) {
|
||||
// Recursively descend the directory to remove its content
|
||||
std::string cmd("/bin/rm -rf ");
|
||||
cmd += path;
|
||||
system(cmd.c_str());
|
||||
} else {
|
||||
// Otherwise, try to just remove the one directory
|
||||
char pathname[MAXPATHLEN];
|
||||
path.copy(pathname,MAXPATHLEN);
|
||||
int lastchar = path.length() - 1 ;
|
||||
if (pathname[lastchar] == '/')
|
||||
pathname[lastchar] = 0;
|
||||
else
|
||||
pathname[lastchar+1] = 0;
|
||||
if ( 0 != rmdir(pathname))
|
||||
ThrowErrno(std::string(pathname) + ": can't destroy directory");
|
||||
if (isFile()) {
|
||||
if (0 != unlink(path.c_str()))
|
||||
ThrowErrno(path + ": can't destroy file");
|
||||
} else if (isDirectory()) {
|
||||
if (remove_contents) {
|
||||
// Recursively descend the directory to remove its content
|
||||
std::string cmd("/bin/rm -rf ");
|
||||
cmd += path;
|
||||
system(cmd.c_str());
|
||||
} else {
|
||||
// Otherwise, try to just remove the one directory
|
||||
char pathname[MAXPATHLEN];
|
||||
path.copy(pathname,MAXPATHLEN);
|
||||
int lastchar = path.length() - 1 ;
|
||||
if (pathname[lastchar] == '/')
|
||||
pathname[lastchar] = 0;
|
||||
else
|
||||
pathname[lastchar+1] = 0;
|
||||
if ( 0 != rmdir(pathname))
|
||||
ThrowErrno(std::string(pathname) + ": can't destroy directory");
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::destroyFile() const {
|
||||
if (!isFile()) return false;
|
||||
if (0 != unlink(path.c_str()))
|
||||
ThrowErrno(path + ": can't destroy file");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::renameFile(const Path& newName) {
|
||||
if (!isFile()) return false;
|
||||
if (0 != rename(path.c_str(), newName.c_str()))
|
||||
Path::rename(const Path& newName) {
|
||||
if (0 != ::rename(path.c_str(), newName.c_str()))
|
||||
ThrowErrno(std::string("can't rename '") + path + "' as '" +
|
||||
newName.toString() + "' ");
|
||||
return true;
|
||||
@ -663,7 +613,6 @@ Path::renameFile(const Path& newName) {
|
||||
|
||||
bool
|
||||
Path::setStatusInfo(const StatusInfo& si) const {
|
||||
if (!isFile()) return false;
|
||||
struct utimbuf utb;
|
||||
utb.actime = si.modTime.toPosixTime();
|
||||
utb.modtime = utb.actime;
|
||||
|
@ -42,7 +42,7 @@ Program::FindProgramByName(const std::string& progName) {
|
||||
if (progName.length() == 0) // no program
|
||||
return Path();
|
||||
Path temp;
|
||||
if (!temp.setFile(progName)) // invalid name
|
||||
if (!temp.set(progName)) // invalid name
|
||||
return Path();
|
||||
// FIXME: have to check for absolute filename - we cannot assume anything
|
||||
// about "." being in $PATH
|
||||
@ -64,8 +64,8 @@ Program::FindProgramByName(const std::string& progName) {
|
||||
|
||||
// Check to see if this first directory contains the executable...
|
||||
Path FilePath;
|
||||
if (FilePath.setDirectory(std::string(PathStr,Colon))) {
|
||||
FilePath.appendFile(progName);
|
||||
if (FilePath.set(std::string(PathStr,Colon))) {
|
||||
FilePath.appendComponent(progName);
|
||||
if (FilePath.canExecute())
|
||||
return FilePath; // Found the executable!
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ RETSIGTYPE SignalHandler(int Sig) {
|
||||
|
||||
if (DirectoriesToRemove != 0)
|
||||
while (!DirectoriesToRemove->empty()) {
|
||||
DirectoriesToRemove->back().destroyDirectory(true);
|
||||
DirectoriesToRemove->back().destroy(true);
|
||||
DirectoriesToRemove->pop_back();
|
||||
}
|
||||
|
||||
|
@ -195,12 +195,18 @@ Path::GetUserHomeDirectory() {
|
||||
|
||||
bool
|
||||
Path::isFile() const {
|
||||
return (isValid() && path[path.length()-1] != '/');
|
||||
WIN32_FILE_ATTRIBUTE_DATA fi;
|
||||
if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi))
|
||||
ThrowError(std::string(path) + ": Can't get status: ");
|
||||
return fi.dwFileAttributes & FILE_ATTRIBUTE_NORMAL;
|
||||
}
|
||||
|
||||
bool
|
||||
Path::isDirectory() const {
|
||||
return (isValid() && path[path.length()-1] == '/');
|
||||
WIN32_FILE_ATTRIBUTE_DATA fi;
|
||||
if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi))
|
||||
ThrowError(std::string(path) + ": Can't get status: ");
|
||||
return fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
||||
}
|
||||
|
||||
std::string
|
||||
|
@ -58,7 +58,7 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
|
||||
if (BD.runPasses(Prefix, PfxOutput))
|
||||
return KeepPrefix;
|
||||
|
||||
PrefixOutput.setFile(PfxOutput);
|
||||
PrefixOutput.set(PfxOutput);
|
||||
OrigProgram = BD.Program;
|
||||
|
||||
BD.Program = ParseInputFile(PrefixOutput.toString());
|
||||
@ -67,7 +67,7 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
|
||||
<< PrefixOutput << "'!\n";
|
||||
exit(1);
|
||||
}
|
||||
PrefixOutput.destroyFile();
|
||||
PrefixOutput.destroy();
|
||||
}
|
||||
|
||||
std::cout << "Checking to see if these passes crash: "
|
||||
|
@ -281,7 +281,7 @@ std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
|
||||
exit(1);
|
||||
|
||||
// Remove the intermediate C file
|
||||
OutputCFile.destroyFile();
|
||||
OutputCFile.destroy();
|
||||
|
||||
return "./" + SharedObjectFile;
|
||||
}
|
||||
@ -302,9 +302,9 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
|
||||
|
||||
// If we're checking the program exit code, assume anything nonzero is bad.
|
||||
if (CheckProgramExitCode && ProgramExitedNonzero) {
|
||||
Output.destroyFile();
|
||||
Output.destroy();
|
||||
if (RemoveBytecode)
|
||||
sys::Path(BytecodeFile).destroyFile();
|
||||
sys::Path(BytecodeFile).destroy();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -321,10 +321,11 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
|
||||
}
|
||||
|
||||
// Remove the generated output.
|
||||
Output.destroyFile();
|
||||
Output.destroy();
|
||||
|
||||
// Remove the bytecode file if we are supposed to.
|
||||
if (RemoveBytecode) sys::Path(BytecodeFile).destroyFile();
|
||||
if (RemoveBytecode)
|
||||
sys::Path(BytecodeFile).destroy();
|
||||
return FilesDifferent;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
|
||||
// If the prefix maintains the predicate by itself, only keep the prefix!
|
||||
if (BD.diffProgram(BytecodeResult)) {
|
||||
std::cout << " nope.\n";
|
||||
sys::Path(BytecodeResult).destroyFile();
|
||||
sys::Path(BytecodeResult).destroy();
|
||||
return KeepPrefix;
|
||||
}
|
||||
std::cout << " yup.\n"; // No miscompilation!
|
||||
@ -113,7 +113,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
|
||||
<< BytecodeResult << "'!\n";
|
||||
exit(1);
|
||||
}
|
||||
sys::Path(BytecodeResult).destroyFile(); // No longer need the file on disk
|
||||
sys::Path(BytecodeResult).destroy(); // No longer need the file on disk
|
||||
|
||||
// Don't check if there are no passes in the suffix.
|
||||
if (Suffix.empty())
|
||||
@ -775,9 +775,9 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
|
||||
std::cerr << ": still failing!\n";
|
||||
else
|
||||
std::cerr << ": didn't fail.\n";
|
||||
TestModuleBC.destroyFile();
|
||||
SafeModuleBC.destroyFile();
|
||||
sys::Path(SharedObject).destroyFile();
|
||||
TestModuleBC.destroy();
|
||||
SafeModuleBC.destroy();
|
||||
sys::Path(SharedObject).destroy();
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
||||
// If we are supposed to delete the bytecode file or if the passes crashed,
|
||||
// remove it now. This may fail if the file was never created, but that's ok.
|
||||
if (DeleteOutput || !ExitedOK)
|
||||
sys::Path(OutputFilename).destroyFile();
|
||||
sys::Path(OutputFilename).destroy();
|
||||
|
||||
#ifndef PLATFORMINDEPENDENT
|
||||
if (!Quiet) {
|
||||
@ -214,6 +214,6 @@ Module *BugDriver::runPassesOn(Module *M,
|
||||
<< BytecodeResult << "'!\n";
|
||||
exit(1);
|
||||
}
|
||||
sys::Path(BytecodeResult).destroyFile(); // No longer need the file on disk
|
||||
sys::Path(BytecodeResult).destroy(); // No longer need the file on disk
|
||||
return Ret;
|
||||
}
|
||||
|
@ -152,15 +152,11 @@ static bool isBytecodeLibrary(const sys::Path &FullPath) {
|
||||
static bool isBytecodeLPath(const std::string &LibPath) {
|
||||
bool isBytecodeLPath = false;
|
||||
|
||||
// Make sure the -L path has a '/' character
|
||||
// because llvm-g++ passes them without the ending
|
||||
// '/' char and sys::Path doesn't think it is a
|
||||
// directory (see: sys::Path::isDirectory) without it
|
||||
std::string dir = LibPath;
|
||||
if ( dir[dir.length()-1] != '/' )
|
||||
dir.append("/");
|
||||
sys::Path LPath(LibPath);
|
||||
|
||||
sys::Path LPath(dir);
|
||||
// Make sure its a directory
|
||||
if (!LPath.isDirectory())
|
||||
return isBytecodeLPath;
|
||||
|
||||
// Grab the contents of the -L path
|
||||
std::set<sys::Path> Files;
|
||||
|
@ -313,9 +313,9 @@ int main(int argc, char **argv, char **envp ) {
|
||||
|
||||
if (!SaveTemps) {
|
||||
// Remove the assembly language file.
|
||||
AssemblyFile.destroyFile();
|
||||
AssemblyFile.destroy();
|
||||
// Remove the bytecode language file.
|
||||
sys::Path(RealBytecodeOutput).destroyFile();
|
||||
sys::Path(RealBytecodeOutput).destroy();
|
||||
}
|
||||
|
||||
} else if (NativeCBE) {
|
||||
@ -345,9 +345,9 @@ int main(int argc, char **argv, char **envp ) {
|
||||
|
||||
if (!SaveTemps) {
|
||||
// Remove the assembly language file.
|
||||
CFile.destroyFile();
|
||||
CFile.destroy();
|
||||
// Remove the bytecode language file.
|
||||
sys::Path(RealBytecodeOutput).destroyFile();
|
||||
sys::Path(RealBytecodeOutput).destroy();
|
||||
}
|
||||
|
||||
} else if (!LinkAsLibrary) {
|
||||
|
@ -293,7 +293,7 @@ std::set<sys::Path> recurseDirectories(const sys::Path& path) {
|
||||
void buildPaths(bool checkExistence = true) {
|
||||
for (unsigned i = 0; i < Members.size(); i++) {
|
||||
sys::Path aPath;
|
||||
if (!aPath.setFile(Members[i]))
|
||||
if (!aPath.set(Members[i]))
|
||||
throw std::string("File member name invalid: ") + Members[i];
|
||||
if (checkExistence) {
|
||||
if (!aPath.exists())
|
||||
@ -431,7 +431,7 @@ void doExtract() {
|
||||
// Make sure the intervening directories are created
|
||||
if (I->hasPath()) {
|
||||
sys::Path dirs(I->getPath());
|
||||
dirs.elideFile();
|
||||
dirs.eraseComponent();
|
||||
dirs.createDirectory(/*create_parents=*/true);
|
||||
}
|
||||
|
||||
@ -669,7 +669,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Check the path name of the archive
|
||||
sys::Path ArchivePath;
|
||||
if (!ArchivePath.setFile(ArchiveName))
|
||||
if (!ArchivePath.set(ArchiveName))
|
||||
throw std::string("Archive name invalid: ") + ArchiveName;
|
||||
|
||||
// Create or open the archive object.
|
||||
|
@ -480,7 +480,7 @@ int main(int argc, char **argv, char **envp) {
|
||||
gcc, envp);
|
||||
|
||||
// Remove the assembly language file.
|
||||
AssemblyFile.destroyFile();
|
||||
AssemblyFile.destroy();
|
||||
} else if (NativeCBE) {
|
||||
sys::Path CFile (OutputFilename);
|
||||
CFile.appendSuffix("cbe.c");
|
||||
@ -505,7 +505,7 @@ int main(int argc, char **argv, char **envp) {
|
||||
GenerateNative(OutputFilename, CFile.toString(), Libraries, gcc, envp);
|
||||
|
||||
// Remove the assembly language file.
|
||||
CFile.destroyFile();
|
||||
CFile.destroy();
|
||||
|
||||
} else {
|
||||
EmitShellScript(argv);
|
||||
|
@ -50,7 +50,7 @@ static cl::opt<bool> NoCompress("disable-compression", cl::init(false),
|
||||
//
|
||||
static inline std::auto_ptr<Module> LoadFile(const std::string &FN) {
|
||||
sys::Path Filename;
|
||||
if (!Filename.setFile(FN)) {
|
||||
if (!Filename.set(FN)) {
|
||||
std::cerr << "Invalid file name: '" << FN << "'\n";
|
||||
return std::auto_ptr<Module>();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Check the path name of the archive
|
||||
sys::Path ArchivePath;
|
||||
if (!ArchivePath.setFile(ArchiveName))
|
||||
if (!ArchivePath.set(ArchiveName))
|
||||
throw std::string("Archive name invalid: ") + ArchiveName;
|
||||
|
||||
// Make sure it exists, we don't create empty archives
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
StringVector::const_iterator E = paths.end();
|
||||
while (I != E) {
|
||||
sys::Path tmp;
|
||||
tmp.setDirectory(*I);
|
||||
tmp.set(*I);
|
||||
IncludePaths.push_back(tmp);
|
||||
++I;
|
||||
}
|
||||
@ -149,7 +149,7 @@ public:
|
||||
StringVector::const_iterator E = paths.end();
|
||||
while (I != E) {
|
||||
sys::Path tmp;
|
||||
tmp.setDirectory(*I);
|
||||
tmp.set(*I);
|
||||
LibraryPaths.push_back(tmp);
|
||||
++I;
|
||||
}
|
||||
@ -188,7 +188,7 @@ private:
|
||||
void cleanup() {
|
||||
if (!isSet(KEEP_TEMPS_FLAG)) {
|
||||
if (TempDir.isDirectory() && TempDir.canWrite())
|
||||
TempDir.destroyDirectory(/*remove_contents=*/true);
|
||||
TempDir.destroy(/*remove_contents=*/true);
|
||||
} else {
|
||||
std::cout << "Temporary files are in " << TempDir << "\n";
|
||||
}
|
||||
@ -197,7 +197,7 @@ private:
|
||||
sys::Path MakeTempFile(const std::string& basename,
|
||||
const std::string& suffix) {
|
||||
sys::Path result(TempDir);
|
||||
if (!result.appendFile(basename))
|
||||
if (!result.appendComponent(basename))
|
||||
throw basename + ": can't use this file name";
|
||||
if (!result.appendSuffix(suffix))
|
||||
throw suffix + ": can't use this file suffix";
|
||||
@ -448,13 +448,13 @@ private:
|
||||
llvm::sys::Path GetPathForLinkageItem(const std::string& link_item,
|
||||
bool native = false) {
|
||||
sys::Path fullpath;
|
||||
fullpath.setFile(link_item);
|
||||
fullpath.set(link_item);
|
||||
if (fullpath.canRead())
|
||||
return fullpath;
|
||||
for (PathVector::iterator PI = LibraryPaths.begin(),
|
||||
PE = LibraryPaths.end(); PI != PE; ++PI) {
|
||||
fullpath.setDirectory(PI->toString());
|
||||
fullpath.appendFile(link_item);
|
||||
fullpath.set(PI->toString());
|
||||
fullpath.appendComponent(link_item);
|
||||
if (fullpath.canRead())
|
||||
return fullpath;
|
||||
if (native) {
|
||||
@ -463,16 +463,16 @@ private:
|
||||
fullpath.appendSuffix("bc");
|
||||
if (fullpath.canRead())
|
||||
return fullpath;
|
||||
fullpath.elideSuffix();
|
||||
fullpath.eraseSuffix();
|
||||
fullpath.appendSuffix("o");
|
||||
if (fullpath.canRead())
|
||||
return fullpath;
|
||||
fullpath = *PI;
|
||||
fullpath.appendFile(std::string("lib") + link_item);
|
||||
fullpath.appendComponent(std::string("lib") + link_item);
|
||||
fullpath.appendSuffix("a");
|
||||
if (fullpath.canRead())
|
||||
return fullpath;
|
||||
fullpath.elideSuffix();
|
||||
fullpath.eraseSuffix();
|
||||
fullpath.appendSuffix("so");
|
||||
if (fullpath.canRead())
|
||||
return fullpath;
|
||||
@ -693,7 +693,7 @@ public:
|
||||
/// The output of the translator is an LLVM Assembly program
|
||||
/// We need to translate it to bytecode
|
||||
Action* action = new Action();
|
||||
action->program.setFile("llvm-as");
|
||||
action->program.set("llvm-as");
|
||||
action->args.push_back(InFile.toString());
|
||||
action->args.push_back("-o");
|
||||
InFile.appendSuffix("bc");
|
||||
@ -735,7 +735,7 @@ public:
|
||||
/// The output of the optimizer is an LLVM Assembly program
|
||||
/// We need to translate it to bytecode with llvm-as
|
||||
Action* action = new Action();
|
||||
action->program.setFile("llvm-as");
|
||||
action->program.set("llvm-as");
|
||||
action->args.push_back(InFile.toString());
|
||||
action->args.push_back("-f");
|
||||
action->args.push_back("-o");
|
||||
@ -764,7 +764,7 @@ public:
|
||||
Action* action = new Action();
|
||||
if (isSet(EMIT_NATIVE_FLAG)) {
|
||||
// Use llc to get the native assembly file
|
||||
action->program.setFile("llc");
|
||||
action->program.set("llc");
|
||||
action->args.push_back(InFile.toString());
|
||||
action->args.push_back("-f");
|
||||
action->args.push_back("-o");
|
||||
@ -777,7 +777,7 @@ public:
|
||||
actions.push_back(action);
|
||||
} else {
|
||||
// Just convert back to llvm assembly with llvm-dis
|
||||
action->program.setFile("llvm-dis");
|
||||
action->program.set("llvm-dis");
|
||||
action->args.push_back(InFile.toString());
|
||||
action->args.push_back("-f");
|
||||
action->args.push_back("-o");
|
||||
@ -820,7 +820,7 @@ public:
|
||||
|
||||
// Set up the linking action with llvm-ld
|
||||
Action* link = new Action();
|
||||
link->program.setFile("llvm-ld");
|
||||
link->program.set("llvm-ld");
|
||||
|
||||
// Add in the optimization level requested
|
||||
switch (optLevel) {
|
||||
|
@ -318,7 +318,7 @@ namespace {
|
||||
{
|
||||
std::string progname;
|
||||
if (parseProgramName(progname))
|
||||
action.program.setFile(progname);
|
||||
action.program.set(progname);
|
||||
else
|
||||
error("Expecting a program name");
|
||||
|
||||
@ -547,8 +547,8 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
|
||||
// Try the environment variable
|
||||
const char* conf = getenv("LLVM_CONFIG_DIR");
|
||||
if (conf) {
|
||||
confFile.setDirectory(conf);
|
||||
confFile.appendFile(ftype);
|
||||
confFile.set(conf);
|
||||
confFile.appendComponent(ftype);
|
||||
if (!confFile.canRead())
|
||||
throw std::string("Configuration file for '") + ftype +
|
||||
"' is not available.";
|
||||
@ -556,20 +556,20 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
|
||||
// Try the user's home directory
|
||||
confFile = sys::Path::GetUserHomeDirectory();
|
||||
if (!confFile.isEmpty()) {
|
||||
confFile.appendDirectory(".llvm");
|
||||
confFile.appendDirectory("etc");
|
||||
confFile.appendFile(ftype);
|
||||
confFile.appendComponent(".llvm");
|
||||
confFile.appendComponent("etc");
|
||||
confFile.appendComponent(ftype);
|
||||
if (!confFile.canRead())
|
||||
confFile.clear();
|
||||
}
|
||||
if (confFile.isEmpty()) {
|
||||
// Okay, try the LLVM installation directory
|
||||
confFile = sys::Path::GetLLVMConfigDir();
|
||||
confFile.appendFile(ftype);
|
||||
confFile.appendComponent(ftype);
|
||||
if (!confFile.canRead()) {
|
||||
// Okay, try the "standard" place
|
||||
confFile = sys::Path::GetLLVMDefaultConfigDir();
|
||||
confFile.appendFile(ftype);
|
||||
confFile.appendComponent(ftype);
|
||||
if (!confFile.canRead()) {
|
||||
throw std::string("Configuration file for '") + ftype +
|
||||
"' is not available.";
|
||||
@ -579,7 +579,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
|
||||
}
|
||||
} else {
|
||||
confFile = configDir;
|
||||
confFile.appendFile(ftype);
|
||||
confFile.appendComponent(ftype);
|
||||
if (!confFile.canRead())
|
||||
throw std::string("Configuration file for '") + ftype +
|
||||
"' is not available.";
|
||||
|
Loading…
x
Reference in New Issue
Block a user