Correctly translate errors from mmap() into exceptions.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150602 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doug Cutting 2004-10-13 17:19:06 +00:00
parent c429a5f1e6
commit 55e076372a
1 changed files with 4 additions and 2 deletions

View File

@ -39,11 +39,13 @@ void GCJIndexInput::open() {
fileLength = sb.st_size; fileLength = sb.st_size;
// mmap the file // mmap the file
data = RAW(::mmap(0, fileLength, PROT_READ, MAP_SHARED, fd, 0)); // cout << "mmapping " << buf << "\n";
if (data < 0) void* address = ::mmap(0, fileLength, PROT_READ, MAP_SHARED, fd, 0);
if (address == MAP_FAILED)
throw new IOException(JvNewStringLatin1(strerror(errno))); throw new IOException(JvNewStringLatin1(strerror(errno)));
// initialize pointer to the start of the file // initialize pointer to the start of the file
data = RAW(address);
pointer = data; pointer = data;
} }