Add isReadable, isUpdateable, isDeletable, isShareable

This commit is contained in:
Robin Appelman 2014-01-24 15:54:40 +01:00
parent 3971b12768
commit fc5f20112e
2 changed files with 65 additions and 1 deletions

View File

@ -122,7 +122,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess, \JsonSerializable {
/**
* @return int
*/
public function getMtime() {
public function getMTime() {
return $this->data['mtime'];
}
@ -150,4 +150,40 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess, \JsonSerializable {
public function getData(){
return $this->data;
}
/**
* @param int $permissions
* @return bool
*/
protected function checkPermissions($permissions) {
return ($this->getPermissions() & $permissions) === $permissions;
}
/**
* @return bool
*/
public function isReadable() {
return $this->checkPermissions(\OCP\PERMISSION_READ);
}
/**
* @return bool
*/
public function isUpdateable() {
return $this->checkPermissions(\OCP\PERMISSION_UPDATE);
}
/**
* @return bool
*/
public function isDeletable() {
return $this->checkPermissions(\OCP\PERMISSION_DELETE);
}
/**
* @return bool
*/
public function isShareable() {
return $this->checkPermissions(\OCP\PERMISSION_SHARE);
}
}

View File

@ -107,4 +107,32 @@ interface FileInfo {
* @return \OCP\Files\FileInfo::TYPE_FILE | \OCP\Files\FileInfo::TYPE_FOLDER
*/
public function getType();
/**
* Check if the file or folder is readable
*
* @return bool
*/
public function isReadable();
/**
* Check if a file is writable
*
* @return bool
*/
public function isUpdateable();
/**
* Check if a file or folder can be deleted
*
* @return bool
*/
public function isDeletable();
/**
* Check if a file or folder can be shared
*
* @return bool
*/
public function isShareable();
}