//===- Support/FileUtilities.cpp - File System Utilities ------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements a family of utility functions which are useful for doing // various things with files. // //===----------------------------------------------------------------------===// #include "llvm/Support/FileUtilities.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Process.h" #include "llvm/Support/raw_ostream.h" #include <cmath> #include <cstdint> #include <cstdlib> #include <cstring> #include <memory> #include <system_error> usingnamespacellvm; static bool isSignedChar(char C) { … } static bool isExponentChar(char C) { … } static bool isNumberChar(char C) { … } static const char *BackupNumber(const char *Pos, const char *FirstChar) { … } /// EndOfNumber - Return the first character that is not part of the specified /// number. This assumes that the buffer is null terminated, so it won't fall /// off the end. static const char *EndOfNumber(const char *Pos) { … } /// CompareNumbers - compare two numbers, returning true if they are different. static bool CompareNumbers(const char *&F1P, const char *&F2P, const char *F1End, const char *F2End, double AbsTolerance, double RelTolerance, std::string *ErrorMsg) { … } /// DiffFilesWithTolerance - Compare the two files specified, returning 0 if the /// files match, 1 if they are different, and 2 if there is a file error. This /// function differs from DiffFiles in that you can specify an absolute and /// relative FP error that is allowed to exist. If you specify a string to fill /// in for the error option, it will set the string to an error message if an /// error occurs, allowing the caller to distinguish between a failed diff and a /// file system error. /// int llvm::DiffFilesWithTolerance(StringRef NameA, StringRef NameB, double AbsTol, double RelTol, std::string *Error) { … } Expected<FilePermissionsApplier> FilePermissionsApplier::create(StringRef InputFilename) { … } Error FilePermissionsApplier::apply( StringRef OutputFilename, bool CopyDates, std::optional<sys::fs::perms> OverwritePermissions) { … }