set lock status for stream

@param   int   $operation
@return  bool
@since   0.10.0
@see     https://github.com/mikey179/vfsStream/issues/6
@see     https://github.com/mikey179/vfsStream/issues/31
@see     https://github.com/mikey179/vfsStream/issues/40
172023
public function stream_lock(int $operation): bool
    {
        if ((LOCK_NB & $operation) == LOCK_NB) {
            $operation = $operation - LOCK_NB;
        }

        return $this->content->lock($this, $operation);
    }
318461
function stream_seek($offset, $whence)
    {
        if ($whence == SEEK_SET && $offset >= 0) {
            $this->pos = $offset;
        } elseif ($whence == SEEK_CUR && -$offset <= $this->pos) {
            $this->pos += $offset;
        } elseif ($whence == SEEK_END && -$offset <= sizeof($this->data)) {
            $this->pos = strlen($this->data) + $offset;
        } else {
            return false;
        }
        return true;
    }
409451
private function isConfigPermission($operation, $class = null, $field = null)
    {
        $map = $this->getMapConfigPermissions();
        $class = PermissionUtils::getMapAction($class);
        $field = PermissionUtils::getMapAction($field);

        return isset($map[$class][$field][$operation]);
    }
669447
public function set_blocking()
    {
        if (!$this->socket || !is_resource($this->socket)) return false;
        Debug::Log(Debug::DEBUG, 'SOCKET: blocking mode: ON');
        stream_set_blocking($this->socket, true);
        return true;
    }
1050234
public function getOperation($operation)
    {
        $operationId = Utilities::getEntityId(
            $operation,
            'WindowsAzure\MediaServices\Models\Operation'
        );

        return Operation::createFromOptions($this->_getEntity("Operations('{$operationId}')"));
    }
845956
public function setStatus($status)
    {
        if (!in_array($status, static::$allowedStatuses))
        {
            throw new RuntimeException("Unknown transaction status given: {$status}");
        }

        $this->status = $status;

        return $this;
    }
452371
protected function setOperator(?string $operator): bool
    {
        if (!$operator) {
            $this->operator = self::DEFAULT_OPERATOR;

            return true;
        }

        if (in_array($operator, self::SUPPORTED_OPERATORS)) {
            $this->operator = $operator;

            return true;
        }

        throw new Exception("Not supported operator");
    }
1192489
private function runOperation(Operation $operation)
    {
        try {
            return $this->runner->run($operation);
        } catch (\Throwable $e) {
            // treated below
        } catch (\Exception $e) {
            // treated below
        }

        // @todo keep only inner if once ExceptionCatcher is gone
        if ($this->exceptionCatcherVoter instanceof ThrowableCatcherVoter) {
            if (!$this->exceptionCatcherVoter->shouldCatchThrowable($e)) {
                throw $e;
            }
        } elseif (!$this->exceptionCatcherVoter->shouldCatch($e)) {
            throw $e;
        }

        try {
            $this->waitStrategy->wait();
        } catch (WaiterException $waiterException) {
            throw $e;
        }

        return $this->runOperation($operation);
    }
700614
public function setOperation(\CampaignChain\CoreBundle\Entity\Operation $operation = null)
    {
        $this->operation = $operation;

        $this->setStartDate($this->operation->getStartDate());

        return $this;
    }
1348159
public function isLocked()
    {
        $result = false;
        if(!$this->isNew())
        {
            if(isset($this->locked_on) && isset($this->locked_by))
            {
                $locked  = strtotime($this->locked_on);
                $current = strtotime(gmdate('Y-m-d H:i:s'));

                //Check if the lock has gone stale
                if($current - $locked < $this->_lifetime)
                {
                    $userid = $this->getObject('user')->getId();
                    if($this->locked_by != 0 && $this->locked_by != $userid) {
                        $result= true;
                    }
                }
            }
        }

        return $result;
    }
899183
public function send(Operation $operation): bool
    {
        if(!$this->connected || !$this->connect())
        {
            return false;
        }
        $data = ($this->serialize)($operation);
        $length = strlen($data);
        $data = pack('N', $length) . $data;
        $length += 4;
        $result = fwrite($this->socket, $data, $length);
        if(false === $result)
        {
            $this->close();
        }
        return $length === $result;
    }
716124
public function stream_seek($offset, $whence = SEEK_SET)
    {
        if ($this->stream->isSeekable()) {
            $this->stream->seek($offset, $whence);
            return true;
        }
        return false;
    }
725608
public function setBlocking(int $mode): bool
	{
		if ($this->connected() === false)
		{
			throw new \Exception('Not connected');
		}

		return stream_set_blocking($this->connection, $mode);
	}
2206
public function release(): bool
    {
        $success = true;
        if (is_resource($this->filePointer)) {
            // FIXME: The lockfile should be unlocked at this point but this will again lead to race conditions,
            // so we need to find out how to do this in a safe way. Keeping the lock files is very inode intensive
            // and should therefore change ASAP.
            if (flock($this->filePointer, LOCK_UN) === false) {
                $success = false;
            }
            fclose($this->filePointer);
        }

        return $success;
    }
994380
public function stream_seek(int $offset, int $whence = SEEK_SET): bool
    {
        $this->notAllowed(__FUNCTION__);

        return false;
    }
46413
protected function hasHooks($operation)
    {
        return $this->enableHooks &&
            is_subclass_of($this->class, Hookable::class) &&
            (method_exists($this->class, "before$operation") || method_exists($this->class, "after$operation"));
    }
492258
public function withinTransaction(callable $operation)
    {
        if ($this->isInTransaction()) {
            return $operation();
        }

        $this->beginTransaction();
        try {
            $result = $operation();
            $this->commitTransaction();

            return $result;
        } catch (\Exception $e) {
            $this->rollbackTransaction();
            throw $e;
        }
    }