1 //===- Support/FileUtilities.h - File System Utilities ----------*- C++ -*-===//
3 // This file defines a family of utility functions which are useful for doing
4 // various things with files.
6 //===----------------------------------------------------------------------===//
8 #ifndef SUPPORT_FILEUTILITIES_H
9 #define SUPPORT_FILEUTILITIES_H
13 /// DiffFiles - Compare the two files specified, returning true if they are
14 /// different or if there is a file error. If you specify a string to fill in
15 /// for the error option, it will set the string to an error message if an error
16 /// occurs, allowing the caller to distinguish between a failed diff and a file
19 bool DiffFiles(const std::string &FileA, const std::string &FileB,
20 std::string *Error = 0);
23 /// MoveFileOverIfUpdated - If the file specified by New is different than Old,
24 /// or if Old does not exist, move the New file over the Old file. Otherwise,
25 /// remove the New file.
27 void MoveFileOverIfUpdated(const std::string &New, const std::string &Old);
29 /// removeFile - Delete the specified file
31 void removeFile(const std::string &Filename);
33 /// getUniqueFilename - Return a filename with the specified prefix. If the
34 /// file does not exist yet, return it, otherwise add a suffix to make it
37 std::string getUniqueFilename(const std::string &FilenameBase);
40 /// Method: MakeFileExecutable()
43 /// This method turns on whatever access attributes are needed to make the
44 /// specified file executable.
47 /// True - The operation succeeded.
48 /// False - The operation failed.
51 /// In case of failure, the file's access attributes are unspecified.
53 bool MakeFileExecutable (const std::string & Filename);
56 /// Method: MakeFileReadable()
59 /// This method turns on whatever access attributes are needed to make the
60 /// specified file readable.
63 /// True - The operation succeeded.
64 /// False - The operation failed.
67 /// In case of failure, the file's access attributes are unspecified.
69 bool MakeFileReadable (const std::string & Filename);