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 /// 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
26 bool DiffFiles(const std::string &FileA, const std::string &FileB,
27 std::string *Error = 0);
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.
34 void MoveFileOverIfUpdated(const std::string &New, const std::string &Old);
36 /// removeFile - Delete the specified file
38 void removeFile(const std::string &Filename);
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
44 std::string getUniqueFilename(const std::string &FilenameBase);
47 /// Method: MakeFileExecutable()
50 /// This method turns on whatever access attributes are needed to make the
51 /// specified file executable.
54 /// True - The operation succeeded.
55 /// False - The operation failed.
58 /// In case of failure, the file's access attributes are unspecified.
60 bool MakeFileExecutable (const std::string & Filename);
63 /// Method: MakeFileReadable()
66 /// This method turns on whatever access attributes are needed to make the
67 /// specified file readable.
70 /// True - The operation succeeded.
71 /// False - The operation failed.
74 /// In case of failure, the file's access attributes are unspecified.
76 bool MakeFileReadable (const std::string & Filename);