2007-01-28 Michele Sandri <gpointorama@gmail.com>

* gnu/java/nio/channels/natFileChannelWin32.cc
	(lock): Implemented.
	(unlock): Implemented.

From-SVN: r121265
This commit is contained in:
Michele Sandri 2007-01-28 18:55:36 +00:00 committed by Mohan Embar
parent 226a2e08e5
commit 94468b1ceb
2 changed files with 47 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2007-01-28 Michele Sandri <gpointorama@gmail.com>
* gnu/java/nio/channels/natFileChannelWin32.cc
(lock): Implemented.
(unlock): Implemented.
2007-01-27 Andreas Tobler <a.tobler@schweiz.org>
PR libgcj/30513

View File

@ -343,18 +343,52 @@ FileChannelImpl::available (void)
}
jboolean
FileChannelImpl::lock
(jlong /*pos*/, jlong /*len*/, jboolean /*shared*/, jboolean /*wait*/)
FileChannelImpl::lock (jlong pos, jlong len, jboolean shared, jboolean wait)
{
throw new IOException (JvNewStringLatin1
("FileChannel.lock() not implemented"));
DWORD flags = 0;
OVERLAPPED ovlpd;
ZeroMemory(&ovlpd,sizeof(OVERLAPPED));
if(!shared)
flags |= LOCKFILE_EXCLUSIVE_LOCK;
if(!wait)
flags |= LOCKFILE_FAIL_IMMEDIATELY;
ovlpd.Offset = (DWORD)pos;
ovlpd.OffsetHigh = pos>>32;
DWORD lenlow = (DWORD)len;
DWORD lenhigh = len>>32;
BOOL ret = LockFileEx((HANDLE)fd,flags,0,lenlow,lenhigh,&ovlpd);
if(ret==ERROR_IO_PENDING && !shared && wait)
ret = GetOverlappedResult((HANDLE)fd,&ovlpd,NULL,wait);
if(!ret)
_Jv_ThrowIOException(GetLastError());
return true;
}
void
FileChannelImpl::unlock (jlong /*pos*/, jlong /*len*/)
FileChannelImpl::unlock (jlong pos, jlong len)
{
throw new IOException (JvNewStringLatin1
("FileChannel.unlock() not implemented"));
OVERLAPPED ovlpd;
ZeroMemory(&ovlpd,sizeof(OVERLAPPED));
ovlpd.Offset = (DWORD)pos;
ovlpd.OffsetHigh = pos>>32;
DWORD lenlow = (DWORD)len;
DWORD lenhigh = len>>32;
BOOL ret = UnlockFileEx((HANDLE)fd,0,lenlow,lenhigh,&ovlpd);
if(!ret)
_Jv_ThrowIOException(GetLastError());
}
java::nio::MappedByteBuffer *