20 #include <system_error>
22 #if !defined(_MSC_VER) && !defined(__MINGW32__)
31 FileOutputBuffer::FileOutputBuffer(std::unique_ptr<mapped_file_region> R,
32 StringRef Path, StringRef TmpPath,
34 :
Region(std::move(R)), FinalPath(Path), TempPath(TmpPath),
35 IsRegular(IsRegular) {}
37 FileOutputBuffer::~FileOutputBuffer() {
49 bool IsRegular =
true;
50 switch (Stat.
type()) {
51 case sys::fs::file_type::file_not_found:
54 case sys::fs::file_type::regular_file: {
60 case sys::fs::file_type::directory_file:
61 return errc::is_a_directory;
80 if (Flags & F_executable)
109 auto MappedFile = llvm::make_unique<mapped_file_region>(
110 FD, mapped_file_region::readwrite,
Size, 0, EC);
115 return std::error_code(errno, std::generic_category());
118 std::move(MappedFile), FilePath, TempFilePath, IsRegular));
119 return std::move(Buf);
122 std::error_code FileOutputBuffer::commit() {
Represents either an error or a value T.
std::error_code createUniqueFile(const Twine &Model, int &ResultFD, SmallVectorImpl< char > &ResultPath, unsigned Mode=all_read|all_write)
Create a uniquely named file.
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
This class represents a memory mapped file.
file_status - Represents the result of a call to stat and friends.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
FileOutputBuffer - This interface provides simple way to create an in-memory buffer which will be wri...
std::error_code copy_file(const Twine &From, const Twine &To)
Copy the contents of From to To.
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
std::error_code resize_file(int FD, uint64_t Size)
Resize path to size.
void DontRemoveFileOnSignal(StringRef Filename)
This function removes a file from the list of files to be removed on signal delivery.
bool RemoveFileOnSignal(StringRef Filename, std::string *ErrMsg=nullptr)
This function registers signal handlers to ensure that if a signal gets delivered that the named file...
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static std::vector< std::string > Flags
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath)
Create a file in the system temporary directory.
static void rename(GlobalValue *GV)
StringRef - Represent a constant reference to a string, i.e.