mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
add a MemoryBuffer::getOpenFile method, which turns an open
file descriptor into a MemoryBuffer (and closes the FD). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120065 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -187,6 +187,7 @@ public:
|
||||
|
||||
MemoryBuffer *MemoryBuffer::getFile(StringRef Filename, std::string *ErrStr,
|
||||
int64_t FileSize) {
|
||||
// Ensure the path is null terminated.
|
||||
SmallString<256> PathBuf(Filename.begin(), Filename.end());
|
||||
return MemoryBuffer::getFile(PathBuf.c_str(), ErrStr, FileSize);
|
||||
}
|
||||
@ -202,6 +203,12 @@ MemoryBuffer *MemoryBuffer::getFile(const char *Filename, std::string *ErrStr,
|
||||
if (ErrStr) *ErrStr = sys::StrError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return getOpenFile(FD, Filename, ErrStr, FileSize);
|
||||
}
|
||||
|
||||
MemoryBuffer *MemoryBuffer::getOpenFile(int FD, const char *Filename,
|
||||
std::string *ErrStr, int64_t FileSize) {
|
||||
FileCloser FC(FD); // Close FD on return.
|
||||
|
||||
// If we don't know the file size, use fstat to find out. fstat on an open
|
||||
|
Reference in New Issue
Block a user