Change MemoryBuffer::getFile to take a Twine.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193429 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2013-10-25 19:06:52 +00:00
parent a954618c6e
commit 76a74f7253
3 changed files with 15 additions and 15 deletions

View File

@@ -238,14 +238,19 @@ static error_code getMemoryBufferForStream(int FD,
return error_code::success();
}
error_code MemoryBuffer::getFile(StringRef Filename,
static error_code getFileAux(const char *Filename,
OwningPtr<MemoryBuffer> &result, int64_t FileSize,
bool RequiresNullTerminator);
error_code MemoryBuffer::getFile(Twine Filename,
OwningPtr<MemoryBuffer> &result,
int64_t FileSize,
bool RequiresNullTerminator) {
// Ensure the path is null terminated.
SmallString<256> PathBuf(Filename.begin(), Filename.end());
return MemoryBuffer::getFile(PathBuf.c_str(), result, FileSize,
RequiresNullTerminator);
SmallString<256> PathBuf;
StringRef NullTerminatedName = Filename.toNullTerminatedStringRef(PathBuf);
return getFileAux(NullTerminatedName.data(), result, FileSize,
RequiresNullTerminator);
}
static error_code getOpenFileImpl(int FD, const char *Filename,
@@ -253,10 +258,9 @@ static error_code getOpenFileImpl(int FD, const char *Filename,
uint64_t FileSize, uint64_t MapSize,
int64_t Offset, bool RequiresNullTerminator);
error_code MemoryBuffer::getFile(const char *Filename,
OwningPtr<MemoryBuffer> &result,
int64_t FileSize,
bool RequiresNullTerminator) {
static error_code getFileAux(const char *Filename,
OwningPtr<MemoryBuffer> &result, int64_t FileSize,
bool RequiresNullTerminator) {
int FD;
error_code EC = sys::fs::openFileForRead(Filename, FD);
if (EC)