Go to the documentation of this file.
17 #include <system_error>
19 #if !defined(_MSC_VER) && !defined(__MINGW32__)
37 uint8_t *getBufferStart()
const override {
return (uint8_t *)Buffer.data(); }
39 uint8_t *getBufferEnd()
const override {
40 return (uint8_t *)Buffer.data() + Buffer.size();
43 size_t getBufferSize()
const override {
return Buffer.size(); }
45 Error commit()
override {
50 return Temp.keep(FinalPath);
53 ~OnDiskBuffer()
override {
60 void discard()
override {
80 uint8_t *getBufferStart()
const override {
return (uint8_t *)Buffer.base(); }
82 uint8_t *getBufferEnd()
const override {
83 return (uint8_t *)Buffer.base() + BufferSize;
86 size_t getBufferSize()
const override {
return BufferSize; }
88 Error commit()
override {
89 if (FinalPath ==
"-") {
95 using namespace sys::fs;
102 OS <<
StringRef((
const char *)Buffer.base(), BufferSize);
121 return std::make_unique<InMemoryBuffer>(Path, MB, Size,
Mode);
150 return std::make_unique<OnDiskBuffer>(Path,
std::move(File),
162 if (Flags & F_executable)
180 switch (Stat.type()) {
186 if (Flags & F_no_mmap)
std::error_code openFileForWrite(const Twine &Name, int &ResultFD, CreationDisposition Disp=CD_CreateAlways, OpenFlags Flags=OF_None, unsigned Mode=0666)
Opens the file with the given name in a write-only or read-write mode, returning its open file descri...
This is an optimization pass for GlobalISel generic memory operations.
std::error_code resize_file_before_mapping_readwrite(int FD, uint64_t Size)
Resize FD to Size before mapping mapped_file_region::readwrite.
static ErrorSuccess success()
Create a success value.
static MemoryBlock allocateMappedMemory(size_t NumBytes, const MemoryBlock *const NearBlock, unsigned Flags, std::error_code &EC)
This method allocates a block of memory that is suitable for loading dynamically generated code (e....
This class encapsulates the notion of a memory block which has an address and a size.
static Expected< std::unique_ptr< FileOutputBuffer > > createOnDiskBuffer(StringRef Path, size_t Size, unsigned Mode)
Tagged union holding either a T or a Error.
void consumeError(Error Err)
Consume a Error without doing anything.
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Owning version of MemoryBlock.
Represents the result of a call to sys::fs::status().
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
FileOutputBuffer - This interface provides simple way to create an in-memory buffer which will be wri...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
@ CD_CreateAlways
CD_CreateAlways - When opening a file:
@ readwrite
May access map via data and modify it. Written to path.
StringRef - Represent a constant reference to a string, i.e.
static Expected< std::unique_ptr< FileOutputBuffer > > create(StringRef FilePath, size_t Size, unsigned Flags=0)
Factory method to create an OutputBuffer object which manages a read/write buffer of the specified si...
A raw_ostream that writes to a file descriptor.
file_t convertFDToNativeFile(int FD)
Converts from a Posix file descriptor number to a native file handle.
Lightweight error class with error context and mandatory checking.
static Expected< std::unique_ptr< InMemoryBuffer > > createInMemoryBuffer(StringRef Path, size_t Size, unsigned Mode)
Error takeError()
Take ownership of the stored error.
This class represents a memory mapped file.
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
Represents a temporary file.
static Expected< TempFile > create(const Twine &Model, unsigned Mode=all_read|all_write, OpenFlags ExtraFlags=OF_None)
This creates a temporary file with createUniqueFile and schedules it for deletion with sys::RemoveFil...