Made error message more comprehensible.
[oota-llvm.git] / include / Support / FileUtilities.h
1 //===- Support/FileUtilities.h - File System Utilities ----------*- C++ -*-===//
2 //
3 // This file defines a family of utility functions which are useful for doing
4 // various things with files.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef SUPPORT_FILEUTILITIES_H
9 #define SUPPORT_FILEUTILITIES_H
10
11 #include <string>
12
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
17 /// system error.
18 ///
19 bool DiffFiles(const std::string &FileA, const std::string &FileB,
20                std::string *Error = 0);
21
22
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.
26 ///
27 void MoveFileOverIfUpdated(const std::string &New, const std::string &Old);
28  
29 /// removeFile - Delete the specified file
30 ///
31 void removeFile(const std::string &Filename);
32
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
35 /// unique.
36 ///
37 std::string getUniqueFilename(const std::string &FilenameBase);
38
39 ///
40 /// Method: MakeFileExecutable()
41 ///
42 /// Description:
43 ///     This method turns on whatever access attributes are needed to make the
44 ///     specified file executable.
45 ///
46 /// Return value:
47 ///     True  - The operation succeeded.
48 ///     False - The operation failed.
49 ///
50 /// Notes:
51 ///     In case of failure, the file's access attributes are unspecified.
52 ///
53 bool MakeFileExecutable (const std::string & Filename);
54
55 ///
56 /// Method: MakeFileReadable()
57 ///
58 /// Description:
59 ///     This method turns on whatever access attributes are needed to make the
60 ///     specified file readable.
61 ///
62 /// Return value:
63 ///     True  - The operation succeeded.
64 ///     False - The operation failed.
65 ///
66 /// Notes:
67 ///     In case of failure, the file's access attributes are unspecified.
68 ///
69 bool MakeFileReadable (const std::string & Filename);
70
71 #endif