nextcloud/lib/public/files/lock.php

63 lines
1.7 KiB
PHP
Raw Normal View History

2014-05-21 01:44:57 +04:00
<?php
/**
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files;
2014-05-21 01:44:57 +04:00
/**
* Class Lock
* @package OC\Files
*/
interface Lock {
2014-05-21 01:44:57 +04:00
const READ = 1;
const WRITE = 2;
2014-05-23 18:29:37 +04:00
/**
* Constructor for the lock instance
* @param string $path Absolute pathname for a local file on which to obtain a lock
*/
public function __construct($path);
2014-05-23 18:29:37 +04:00
/**
* Add a lock of a specific type to the stack
* @param integer $lockType A constant representing the type of lock to queue
* @param null|resource $existingHandle An existing file handle from an fopen()
* @throws LockNotAcquiredException
*/
public function addLock($lockType, $existingHandle = null);
2014-05-21 01:44:57 +04:00
/**
* Release locks on handles and files
*/
public function release($lockType);
2014-05-21 01:44:57 +04:00
/**
* Get the lock file associated to a file
* @param string $filename The filename of the file to create a lock file for
* @return string The filename of the lock file
*/
public static function getLockFile($filename);
2014-05-23 18:29:37 +04:00
/**
* Release all queued locks on the file
* @return bool
*/
public function releaseAll();
2014-05-21 01:44:57 +04:00
}