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:
parent
4a642fc004
commit
e5c3e4b76f
|
@ -169,4 +169,8 @@ class TrashItem implements ITrashItem {
|
|||
public function getChecksum() {
|
||||
return $this->fileInfo->getChecksum();
|
||||
}
|
||||
|
||||
public function getExtension(): string {
|
||||
return $this->fileInfo->getExtension();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue