Added LLVM notice.
[oota-llvm.git] / include / llvm / Support / FileUtilities.h
1 //===- Support/FileUtilities.h - File System Utilities ----------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines a family of utility functions which are useful for doing
11 // various things with files.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef SUPPORT_FILEUTILITIES_H
16 #define SUPPORT_FILEUTILITIES_H
17
18 #include <string>
19
20 /// DiffFiles - Compare the two files specified, returning true if they are
21 /// different or if there is a file error.  If you specify a string to fill in
22 /// for the error option, it will set the string to an error message if an error
23 /// occurs, allowing the caller to distinguish between a failed diff and a file
24 /// system error.
25 ///
26 bool DiffFiles(const std::string &FileA, const std::string &FileB,
27                std::string *Error = 0);
28
29
30 /// MoveFileOverIfUpdated - If the file specified by New is different than Old,
31 /// or if Old does not exist, move the New file over the Old file.  Otherwise,
32 /// remove the New file.
33 ///
34 void MoveFileOverIfUpdated(const std::string &New, const std::string &Old);
35  
36 /// removeFile - Delete the specified file
37 ///
38 void removeFile(const std::string &Filename);
39
40 /// getUniqueFilename - Return a filename with the specified prefix.  If the
41 /// file does not exist yet, return it, otherwise add a suffix to make it
42 /// unique.
43 ///
44 std::string getUniqueFilename(const std::string &FilenameBase);
45
46 ///
47 /// Method: MakeFileExecutable()
48 ///
49 /// Description:
50 ///     This method turns on whatever access attributes are needed to make the
51 ///     specified file executable.
52 ///
53 /// Return value:
54 ///     True  - The operation succeeded.
55 ///     False - The operation failed.
56 ///
57 /// Notes:
58 ///     In case of failure, the file's access attributes are unspecified.
59 ///
60 bool MakeFileExecutable (const std::string & Filename);
61
62 ///
63 /// Method: MakeFileReadable()
64 ///
65 /// Description:
66 ///     This method turns on whatever access attributes are needed to make the
67 ///     specified file readable.
68 ///
69 /// Return value:
70 ///     True  - The operation succeeded.
71 ///     False - The operation failed.
72 ///
73 /// Notes:
74 ///     In case of failure, the file's access attributes are unspecified.
75 ///
76 bool MakeFileReadable (const std::string & Filename);
77
78 #endif