mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-13 17:00:01 +00:00
[Support] Allow discarding a FileOutputBuffer without removing the memory mapping
Differential Revision: https://reviews.llvm.org/D51095 llvm-svn: 340634
This commit is contained in:
parent
147119c3ce
commit
084c5476f3
@ -76,6 +76,10 @@ public:
|
||||
/// deallocates the buffer and the target file is never written.
|
||||
virtual ~FileOutputBuffer() {}
|
||||
|
||||
/// This removes the temporary file (unless it already was committed)
|
||||
/// but keeps the memory mapping alive.
|
||||
virtual void discard() {}
|
||||
|
||||
protected:
|
||||
FileOutputBuffer(StringRef Path) : FinalPath(Path) {}
|
||||
|
||||
|
@ -61,6 +61,12 @@ public:
|
||||
consumeError(Temp.discard());
|
||||
}
|
||||
|
||||
void discard() override {
|
||||
// Delete the temp file if it still was open, but keeping the mapping
|
||||
// active.
|
||||
consumeError(Temp.discard());
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<fs::mapped_file_region> Buffer;
|
||||
fs::TempFile Temp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user