Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. vfsStreamFile.php

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\vfs

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal