forked from OSchip/llvm-project
<rdar://problem/10647191>
Removed an extra call to close that was causing problems and also now use the Host::File class to open the file. llvm-svn: 147638
This commit is contained in:
parent
b49440fa92
commit
650e3b014e
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "lldb/Core/DataBufferMemoryMap.h"
|
||||
#include "lldb/Core/Error.h"
|
||||
#include "lldb/Host/File.h"
|
||||
#include "lldb/Host/FileSpec.h"
|
||||
#include "lldb/Host/Host.h"
|
||||
|
||||
|
@ -106,25 +107,18 @@ DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* file,
|
|||
char path[PATH_MAX];
|
||||
if (file->GetPath(path, sizeof(path)))
|
||||
{
|
||||
int oflag = 0;
|
||||
uint32_t options = File::eOpenOptionRead;
|
||||
if (writeable)
|
||||
oflag = O_RDWR;
|
||||
else
|
||||
oflag = O_RDONLY;
|
||||
options |= File::eOpenOptionWrite;
|
||||
|
||||
int fd = ::open(path, oflag, 0);
|
||||
if (fd >= 0)
|
||||
File file;
|
||||
Error error (file.Open(path, options));
|
||||
if (error.Success())
|
||||
{
|
||||
const bool fd_is_file = true;
|
||||
MemoryMapFromFileDescriptor (fd, offset, length, writeable, fd_is_file);
|
||||
::close(fd);
|
||||
MemoryMapFromFileDescriptor (file.GetDescriptor(), offset, length, writeable, fd_is_file);
|
||||
return GetByteSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
//error.SetErrorToErrno();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// We should only get here if there was an error
|
||||
|
@ -225,8 +219,6 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
::close (fd);
|
||||
}
|
||||
return GetByteSize ();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue