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