aboutsummaryrefslogtreecommitdiffstats
path: root/lib/files/file.php
blob: 0d33cea7ee77892b8beb2d6c72863ed29ff8a6b3 (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
<?php
/**
 * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace OC\Files;

/**
 * representation of the location a file or folder is stored
 */

class File{
	/**
	 * @var Storage\Storage $storage
	 */
	private $storage;
	/**
	 * @var string internalPath
	 */
	private $internalPath;

	public function __construct(Storage\Storage $storage, $internalPath){
		$this->storage = $storage;
		$this->internalPath = $internalPath;
	}

	public static function resolve($fullPath){
		$storage = null;
		$internalPath = '';
		list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($fullPath);
		return new File($storage, $internalPath);
	}

	/**
	 * get the internal path of the file inside the filestorage
	 * @return string
	 */
	public function getInternalPath(){
		return $this->internalPath;
	}

	/**
	 * get the storage the file is stored in
	 * @return  \OC\Files\Storage\Storage
	 */
	public function getStorage(){
		return $this->storage;
	}

	/**
	 * get the id of the storage the file is stored in
	 * @return string
	 */
	public function getStorageId(){
		return $this->storage->getId();
	}
	
}