diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-01-13 14:28:49 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-01-13 14:28:49 +0100 |
commit | 617acbd6f9e93254c31987639cc4915dceb7c4c0 (patch) | |
tree | f23296b22fbd833809ebf1ca5598208a425c1c31 /lib/private/files/fileinfo.php | |
parent | 85e00ad35a63d2d728140f3ece685d79d7a6140c (diff) | |
download | nextcloud-server-617acbd6f9e93254c31987639cc4915dceb7c4c0.tar.gz nextcloud-server-617acbd6f9e93254c31987639cc4915dceb7c4c0.zip |
Add a FileInfo class which holds all info of a file and return that from getFileInfo, getDirectoryContent and search
Diffstat (limited to 'lib/private/files/fileinfo.php')
-rw-r--r-- | lib/private/files/fileinfo.php | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php new file mode 100644 index 00000000000..24d99627aaf --- /dev/null +++ b/lib/private/files/fileinfo.php @@ -0,0 +1,149 @@ +<?php +/** + * Copyright (c) 2013 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; + +class FileInfo implements \OCP\Files\FileInfo { + /** + * @var array $data + */ + private $data; + + /** + * @var string $path + */ + private $path; + + /** + * @var \OC\Files\Storage\Storage $storage + */ + private $storage; + + /** + * @var string $internalPath + */ + private $internalPath; + + public function __construct($path, $storage, $internalPath, $data) { + $this->path = $path; + $this->storage = $storage; + $this->internalPath = $internalPath; + $this->data = $data; + } + + public function offsetSet($offset, $value) { + $this->data[$offset] = $value; + } + + public function offsetExists($offset) { + return isset($this->data[$offset]); + } + + public function offsetUnset($offset) { + unset($this->data[$offset]); + } + + public function offsetGet($offset) { + return $this->data[$offset]; + } + + public function jsonSerialize() { + return $this->data; + } + + /** + * @return string + */ + public function getPath() { + return $this->path; + } + + /** + * @return \OCP\Files\Storage + */ + public function getStorage() { + return $this->storage; + } + + /** + * @return string + */ + public function getInternalPath() { + return $this->internalPath; + } + + /** + * @return int + */ + public function getId() { + return $this->data['fileid']; + } + + /** + * @return string + */ + public function getMimetype() { + return $this->data['mimetype']; + } + + /** + * @return string + */ + public function getMimePart() { + return $this->data['mimepart']; + } + + /** + * @return string + */ + public function getName() { + return $this->data['name']; + } + + /** + * @return string + */ + public function getEtag() { + return $this->data['etag']; + } + + /** + * @return int + */ + public function getSize() { + return $this->data['size']; + } + + /** + * @return int + */ + public function getMtime() { + return $this->data['mtime']; + } + + /** + * @return bool + */ + public function isEncrypted() { + return $this->data['encrypted']; + } + + /** + * @return int + */ + public function getPermissions() { + return $this->data['permissions']; + } + + /** + * @return \OCP\Files\FileInfo::TYPE_FILE | \OCP\Files\FileInfo::TYPE_FOLDER + */ + public function getType() { + return $this->data['type']; + } +} |