Add getExtension() to FileInfo

this is a fairly common operation so it makes sense to prevent having
to repeatedly implement it.

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2018-10-29 15:23:33 +01:00
parent 4a642fc004
commit e5c3e4b76f
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
7 changed files with 36 additions and 0 deletions

View File

@ -169,4 +169,8 @@ class TrashItem implements ITrashItem {
public function getChecksum() {
return $this->fileInfo->getChecksum();
}
public function getExtension(): string {
return $this->fileInfo->getExtension();
}
}

View File

@ -390,4 +390,8 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
public function getChecksum() {
return $this->data['checksum'];
}
public function getExtension(): string {
return pathinfo($this->getName(), PATHINFO_EXTENSION);
}
}

View File

@ -142,4 +142,8 @@ class File extends Node implements \OCP\Files\File {
public function getChecksum() {
return $this->getFileInfo()->getChecksum();
}
public function getExtension(): string {
return $this->getFileInfo()->getExtension();
}
}

View File

@ -344,6 +344,10 @@ class LazyRoot implements IRootFolder {
return $this->__call(__FUNCTION__, func_get_args());
}
public function getExtension(): string {
return $this->__call(__FUNCTION__, func_get_args());
}
/**
* @inheritDoc
*/

View File

@ -354,6 +354,10 @@ class Node implements \OCP\Files\Node {
public function getChecksum() {
}
public function getExtension(): string {
return $this->getFileInfo()->getExtension();
}
/**
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @throws \OCP\Lock\LockedException

View File

@ -96,4 +96,12 @@ interface File extends Node {
* @throws NotFoundException
*/
public function getChecksum();
/**
* Get the extension of this file
*
* @return string
* @since 15.0.0
*/
public function getExtension(): string;
}

View File

@ -259,4 +259,12 @@ interface FileInfo {
* @since 9.0.0
*/
public function getChecksum();
/**
* Get the extension of the file
*
* @return string
* @since 15.0.0
*/
public function getExtension(): string;
}