本文整理了Java中java.nio.channels.FileLock.size()
方法的一些代码示例,展示了FileLock.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileLock.size()
方法的具体详情如下:
包路径:java.nio.channels.FileLock
类名称:FileLock
方法名:size
[英]Returns the length of the file lock in bytes.
[中]返回文件锁的长度(以字节为单位)。
代码示例来源:origin: com.h2database/h2
protected FileLockRetry(FileLock base, FileChannel channel) {
super(channel, base.position(), base.size(), base.isShared());
this.base = base;
}
代码示例来源:origin: robovm/robovm
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: robovm/robovm
/**
* 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);
}
代码示例来源:origin: com.eventsourcing/h2
protected FileLockRetry(FileLock base, FileChannel channel) {
super(channel, base.position(), base.size(), base.isShared());
this.base = base;
}
代码示例来源:origin: org.wowtools/h2
protected FileLockRetry(FileLock base, FileChannel channel) {
super(channel, base.position(), base.size(), base.isShared());
this.base = base;
}
代码示例来源:origin: org.apache.sshd/sshd-sftp
public void unlock(long offset, long length) throws IOException {
SeekableByteChannel channel = getFileChannel();
long size = (length == 0L) ? channel.size() - offset : length;
FileLock lock = null;
for (Iterator<FileLock> iterator = locks.iterator(); iterator.hasNext();) {
FileLock l = iterator.next();
if ((l.position() == offset) && (l.size() == size)) {
iterator.remove();
lock = l;
break;
}
}
if (lock == null) {
throw new SftpException(SftpConstants.SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK,
"No matching lock found on range [" + offset + "-" + (offset + length));
}
lock.release();
}
代码示例来源:origin: ibinti/bugvm
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: MobiVM/robovm
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: com.gluonhq/robovm-rt
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: FlexoVM/flexovm
/**
* Add a new pending lock to the manager. Throws an exception if the lock
* would overlap an existing lock. Once the lock is acquired it remains in
* this set as an acquired lock.
*/
private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
long lockEnd = lock.position() + lock.size();
for (FileLock existingLock : locks) {
if (existingLock.position() > lockEnd) {
// This, and all remaining locks, start beyond our end (so
// cannot overlap).
break;
}
if (existingLock.overlaps(lock.position(), lock.size())) {
throw new OverlappingFileLockException();
}
}
locks.add(lock);
}
代码示例来源:origin: org.tmatesoft.sqljet/sqljet
/**
* @param channel
* @param position
* @param size
* @param shared
*/
public SqlJetFileLock(SqlJetFileLockManager manager, FileLock fileLock) {
super(fileLock.channel(), fileLock.position(), fileLock.size(), fileLock.isShared());
this.manager = manager;
this.fileLock = fileLock;
this.locksCount = 1;
}
代码示例来源:origin: eu.fbk.utils/utils-core
return new FileLock(lock.channel(), lock.position(), lock.size(), lock.isShared()) {
代码示例来源:origin: MobiVM/robovm
/**
* 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);
}
代码示例来源:origin: com.gluonhq/robovm-rt
/**
* 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);
}
代码示例来源:origin: ibinti/bugvm
/**
* 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);
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* 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);
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* 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);
}
代码示例来源:origin: FlexoVM/flexovm
/**
* 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);
}
内容来源于网络,如有侵权,请联系作者删除!