Put all LLVM code into the llvm namespace, as per bug 109.
[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 namespace llvm {
21
22 /// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must
23 /// name a readable file.
24 ///
25 bool CheckMagic (const std::string &FN, const std::string &Magic);
26
27 /// IsArchive - Returns true IFF the file named FN appears to be a "ar" library
28 /// archive. The file named FN must exist.
29 ///
30 bool IsArchive (const std::string &FN);
31
32 /// IsBytecode - Returns true IFF the file named FN appears to be an LLVM
33 /// bytecode file. The file named FN must exist.
34 ///
35 bool IsBytecode (const std::string &FN);
36
37 /// FileOpenable - Returns true IFF Filename names an existing regular file
38 /// which we can successfully open.
39 ///
40 bool FileOpenable (const std::string &Filename);
41
42 /// DiffFiles - Compare the two files specified, returning true if they are
43 /// different or if there is a file error.  If you specify a string to fill in
44 /// for the error option, it will set the string to an error message if an error
45 /// occurs, allowing the caller to distinguish between a failed diff and a file
46 /// system error.
47 ///
48 bool DiffFiles(const std::string &FileA, const std::string &FileB,
49                std::string *Error = 0);
50
51
52 /// MoveFileOverIfUpdated - If the file specified by New is different than Old,
53 /// or if Old does not exist, move the New file over the Old file.  Otherwise,
54 /// remove the New file.
55 ///
56 void MoveFileOverIfUpdated(const std::string &New, const std::string &Old);
57  
58 /// removeFile - Delete the specified file
59 ///
60 void removeFile(const std::string &Filename);
61
62 /// getUniqueFilename - Return a filename with the specified prefix.  If the
63 /// file does not exist yet, return it, otherwise add a suffix to make it
64 /// unique.
65 ///
66 std::string getUniqueFilename(const std::string &FilenameBase);
67
68 ///
69 /// Method: MakeFileExecutable()
70 ///
71 /// Description:
72 ///     This method turns on whatever access attributes are needed to make the
73 ///     specified file executable.
74 ///
75 /// Return value:
76 ///     True  - The operation succeeded.
77 ///     False - The operation failed.
78 ///
79 /// Notes:
80 ///     In case of failure, the file's access attributes are unspecified.
81 ///
82 bool MakeFileExecutable (const std::string & Filename);
83
84 ///
85 /// Method: MakeFileReadable()
86 ///
87 /// Description:
88 ///     This method turns on whatever access attributes are needed to make the
89 ///     specified file readable.
90 ///
91 /// Return value:
92 ///     True  - The operation succeeded.
93 ///     False - The operation failed.
94 ///
95 /// Notes:
96 ///     In case of failure, the file's access attributes are unspecified.
97 ///
98 bool MakeFileReadable (const std::string & Filename);
99
100 } // End llvm namespace
101
102 #endif