summaryrefslogtreecommitdiffstats
path: root/lib/public/files/lock.php
blob: 34d307e89394ddfec6d9d3f104cebd3e094edf5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?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;

/**
 * Class Lock
 * @package OC\Files
 */
interface Lock {
	const READ = 1;
	const WRITE = 2;

	/**
	 * Constructor for the lock instance
	 * @param string $path Absolute pathname for a local file on which to obtain a lock
	 */
	public function __construct($path);


	/**
	 * 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);

	/**
	 * Release locks on handles and files
	 */
	public function release($lockType);


	/**
	 * 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);

	/**
	 * Release all queued locks on the file
	 * @return bool
	 */
	public function releaseAll();

}