Add a FileInfo class which holds all info of a file and return that from getFileInfo, getDirectoryContent and search
parent
85e00ad35a
commit
617acbd6f9
@ -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']; |
||||
} |
||||
} |
||||
@ -0,0 +1,87 @@ |
||||
<?php |
||||
/** |
||||
* Created by PhpStorm. |
||||
* User: robin |
||||
* Date: 1/13/14 |
||||
* Time: 1:45 PM |
||||
*/ |
||||
namespace OCP\Files; |
||||
|
||||
interface FileInfo extends \ArrayAccess, \JsonSerializable { |
||||
const TYPE_FILE = 'file'; |
||||
const TYPE_FOLDER = 'folder'; |
||||
|
||||
public function offsetSet($offset, $value); |
||||
|
||||
public function offsetGet($offset); |
||||
|
||||
public function offsetUnset($offset); |
||||
|
||||
public function offsetExists($offset); |
||||
|
||||
public function jsonSerialize(); |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function getEtag(); |
||||
|
||||
/** |
||||
* @return int |
||||
*/ |
||||
public function getSize(); |
||||
|
||||
/** |
||||
* @return int |
||||
*/ |
||||
public function getMtime(); |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function getName(); |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function getInternalPath(); |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function getPath(); |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function getMimetype(); |
||||
|
||||
/** |
||||
* @return \OCP\Files\Storage |
||||
*/ |
||||
public function getStorage(); |
||||
|
||||
/** |
||||
* @return int |
||||
*/ |
||||
public function getId(); |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function getMimePart(); |
||||
/** |
||||
* @return bool |
||||
*/ |
||||
public function isEncrypted(); |
||||
|
||||
/** |
||||
* @return int |
||||
*/ |
||||
public function getPermissions(); |
||||
|
||||
/** |
||||
* @return \OCP\Files\FileInfo::TYPE_FILE | \OCP\Files\FileInfo::TYPE_FOLDER |
||||
*/ |
||||
public function getType(); |
||||
} |
||||
Loading…
Reference in new issue