Merge pull request #12113 from nextcloud/fileinfo-getextension

Add getExtension() to FileInfo
This commit is contained in:
Morris Jobke 2018-10-29 17:23:27 +01:00 committed by GitHub
commit 963d968f06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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;
}