Search in sources :

Example 6 with StructFlock

use of libcore.io.StructFlock in project robovm by robovm.

the class FileChannelImpl method release.

/**
     * Non-API method to release a given lock on a file channel. Assumes that
     * the lock will mark itself invalid after successful unlocking.
     */
public void release(FileLock lock) throws IOException {
    checkOpen();
    StructFlock flock = new StructFlock();
    flock.l_type = (short) F_UNLCK;
    flock.l_whence = (short) SEEK_SET;
    flock.l_start = lock.position();
    flock.l_len = translateLockLength(lock.size());
    try {
        Libcore.os.fcntlFlock(fd, F_SETLKW64, flock);
    } catch (ErrnoException errnoException) {
        throw errnoException.rethrowAsIOException();
    }
    removeLock(lock);
}
Also used : ErrnoException(libcore.io.ErrnoException) StructFlock(libcore.io.StructFlock)

Aggregations

ErrnoException (libcore.io.ErrnoException)6 StructFlock (libcore.io.StructFlock)6 FileLock (java.nio.channels.FileLock)3 NonReadableChannelException (java.nio.channels.NonReadableChannelException)3 NonWritableChannelException (java.nio.channels.NonWritableChannelException)3