LLVM API Documentation
00001 //===- llvm/Support/FileUtilities.h - File System Utilities -----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines a family of utility functions which are useful for doing 00011 // various things with files. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_SUPPORT_FILEUTILITIES_H 00016 #define LLVM_SUPPORT_FILEUTILITIES_H 00017 00018 #include "llvm/System/Path.h" 00019 00020 namespace llvm { 00021 00022 /// DiffFilesWithTolerance - Compare the two files specified, returning 0 if 00023 /// the files match, 1 if they are different, and 2 if there is a file error. 00024 /// This function allows you to specify an absolete and relative FP error that 00025 /// is allowed to exist. If you specify a string to fill in for the error 00026 /// option, it will set the string to an error message if an error occurs, or 00027 /// if the files are different. 00028 /// 00029 int DiffFilesWithTolerance(const sys::PathWithStatus &FileA, 00030 const sys::PathWithStatus &FileB, 00031 double AbsTol, double RelTol, 00032 std::string *Error = 0); 00033 00034 00035 /// FileRemover - This class is a simple object meant to be stack allocated. 00036 /// If an exception is thrown from a region, the object removes the filename 00037 /// specified (if deleteIt is true). 00038 /// 00039 class FileRemover { 00040 sys::Path Filename; 00041 bool DeleteIt; 00042 public: 00043 explicit FileRemover(const sys::Path &filename, bool deleteIt = true) 00044 : Filename(filename), DeleteIt(deleteIt) {} 00045 00046 ~FileRemover() { 00047 if (DeleteIt) { 00048 // Ignore problems deleting the file. 00049 Filename.eraseFromDisk(); 00050 } 00051 } 00052 00053 /// releaseFile - Take ownership of the file away from the FileRemover so it 00054 /// will not be removed when the object is destroyed. 00055 void releaseFile() { DeleteIt = false; } 00056 }; 00057 } // End llvm namespace 00058 00059 #endif
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.