1 //===- Support/FileUtilities.h - File System Utilities ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file defines a family of utility functions which are useful for doing
11 // various things with files.
13 //===----------------------------------------------------------------------===//
15 #ifndef SUPPORT_FILEUTILITIES_H
16 #define SUPPORT_FILEUTILITIES_H
20 /// FileOpenable - Returns true IFF Filename names an existing regular
21 /// file which we can successfully open.
23 bool FileOpenable (const std::string &Filename);
25 /// DiffFiles - Compare the two files specified, returning true if they are
26 /// different or if there is a file error. If you specify a string to fill in
27 /// for the error option, it will set the string to an error message if an error
28 /// occurs, allowing the caller to distinguish between a failed diff and a file
31 bool DiffFiles(const std::string &FileA, const std::string &FileB,
32 std::string *Error = 0);
35 /// MoveFileOverIfUpdated - If the file specified by New is different than Old,
36 /// or if Old does not exist, move the New file over the Old file. Otherwise,
37 /// remove the New file.
39 void MoveFileOverIfUpdated(const std::string &New, const std::string &Old);
41 /// removeFile - Delete the specified file
43 void removeFile(const std::string &Filename);
45 /// getUniqueFilename - Return a filename with the specified prefix. If the
46 /// file does not exist yet, return it, otherwise add a suffix to make it
49 std::string getUniqueFilename(const std::string &FilenameBase);
52 /// Method: MakeFileExecutable()
55 /// This method turns on whatever access attributes are needed to make the
56 /// specified file executable.
59 /// True - The operation succeeded.
60 /// False - The operation failed.
63 /// In case of failure, the file's access attributes are unspecified.
65 bool MakeFileExecutable (const std::string & Filename);
68 /// Method: MakeFileReadable()
71 /// This method turns on whatever access attributes are needed to make the
72 /// specified file readable.
75 /// True - The operation succeeded.
76 /// False - The operation failed.
79 /// In case of failure, the file's access attributes are unspecified.
81 bool MakeFileReadable (const std::string & Filename);