function vfsStreamFile::lock
locks file for
@since 0.10.0
Parameters
resource|vfsStreamWrapper $resource:
int $operation:
Return value
bool
See also
https://github.com/mikey179/vfsStream/issues/6
https://github.com/mikey179/vfsStream/issues/40
File
-
vendor/
mikey179/ vfsstream/ src/ main/ php/ org/ bovigo/ vfs/ vfsStreamFile.php, line 268
Class
- vfsStreamFile
- File container.
Namespace
org\bovigo\vfsCode
public function lock($resource, $operation) {
if ((LOCK_NB & $operation) == LOCK_NB) {
$operation = $operation - LOCK_NB;
}
// call to lock file on the same file handler firstly releases the lock
$this->unlock($resource);
if (LOCK_EX === $operation) {
if ($this->isLocked()) {
return false;
}
$this->setExclusiveLock($resource);
}
elseif (LOCK_SH === $operation) {
if ($this->hasExclusiveLock()) {
return false;
}
$this->addSharedLock($resource);
}
return true;
}