diff options
author | Robin Appelman <robin@icewind.nl> | 2018-10-29 15:23:33 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-10-29 15:24:02 +0100 |
commit | e5c3e4b76fac1c4a1235781229486f53ffcb93c1 (patch) | |
tree | b0fa6702bc14c23af090277d489dd75493db2803 /lib/private | |
parent | 4a642fc0048c03a24aa199ccc9df23d547f69aa2 (diff) | |
download | nextcloud-server-e5c3e4b76fac1c4a1235781229486f53ffcb93c1.tar.gz nextcloud-server-e5c3e4b76fac1c4a1235781229486f53ffcb93c1.zip |
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>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/FileInfo.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Node/File.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Node/LazyRoot.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Node/Node.php | 4 |
4 files changed, 16 insertions, 0 deletions
diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 53f73f0f95d..575af56ceb5 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -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); + } } diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php index 7c411620ca0..a3eabbcc446 100644 --- a/lib/private/Files/Node/File.php +++ b/lib/private/Files/Node/File.php @@ -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(); + } } diff --git a/lib/private/Files/Node/LazyRoot.php b/lib/private/Files/Node/LazyRoot.php index faa57ecb0b4..389a1a9f0ff 100644 --- a/lib/private/Files/Node/LazyRoot.php +++ b/lib/private/Files/Node/LazyRoot.php @@ -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 */ diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index d2232624b9b..590f1080617 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -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 |