summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2022-03-03 05:10:57 +0000
committerChristopher Ng <chrng8@gmail.com>2022-03-04 06:11:53 +0000
commit0571391b10a48e6d6cbf8abfbe0d2e4a9fc26d0f (patch)
treee58c385d4f66ac1ea3a6bc37ff111c5d1fc466b8
parentf1604cf7afa8d65a3648b7c7e1e6611920fe5f6f (diff)
downloadnextcloud-server-0571391b10a48e6d6cbf8abfbe0d2e4a9fc26d0f.tar.gz
nextcloud-server-0571391b10a48e6d6cbf8abfbe0d2e4a9fc26d0f.zip
Extend simple file with extension getter
Signed-off-by: Christopher Ng <chrng8@gmail.com>
-rw-r--r--lib/private/Files/SimpleFS/NewSimpleFile.php11
-rw-r--r--lib/private/Files/SimpleFS/SimpleFile.php7
-rw-r--r--lib/public/Files/SimpleFS/ISimpleFile.php5
-rw-r--r--lib/public/Files/SimpleFS/InMemoryFile.php7
4 files changed, 30 insertions, 0 deletions
diff --git a/lib/private/Files/SimpleFS/NewSimpleFile.php b/lib/private/Files/SimpleFS/NewSimpleFile.php
index f805403fd87..76fc69ebbe7 100644
--- a/lib/private/Files/SimpleFS/NewSimpleFile.php
+++ b/lib/private/Files/SimpleFS/NewSimpleFile.php
@@ -191,6 +191,17 @@ class NewSimpleFile implements ISimpleFile {
}
/**
+ * {@inheritDoc}
+ */
+ public function getExtension(): string {
+ if ($this->file) {
+ return $this->file->getExtension();
+ } else {
+ return \pathinfo($this->name, PATHINFO_EXTENSION);
+ }
+ }
+
+ /**
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
*
* @return resource
diff --git a/lib/private/Files/SimpleFS/SimpleFile.php b/lib/private/Files/SimpleFS/SimpleFile.php
index baf9b24e020..21a2fd92dcb 100644
--- a/lib/private/Files/SimpleFS/SimpleFile.php
+++ b/lib/private/Files/SimpleFS/SimpleFile.php
@@ -159,6 +159,13 @@ class SimpleFile implements ISimpleFile {
}
/**
+ * {@inheritDoc}
+ */
+ public function getExtension(): string {
+ return $this->file->getExtension();
+ }
+
+ /**
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
*
* @return resource
diff --git a/lib/public/Files/SimpleFS/ISimpleFile.php b/lib/public/Files/SimpleFS/ISimpleFile.php
index 3287c42054f..c0db4cc22e9 100644
--- a/lib/public/Files/SimpleFS/ISimpleFile.php
+++ b/lib/public/Files/SimpleFS/ISimpleFile.php
@@ -103,6 +103,11 @@ interface ISimpleFile {
public function getMimeType();
/**
+ * @since 24.0.0
+ */
+ public function getExtension(): string;
+
+ /**
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
*
* @return resource
diff --git a/lib/public/Files/SimpleFS/InMemoryFile.php b/lib/public/Files/SimpleFS/InMemoryFile.php
index 6020b42d953..4606fe9bd8a 100644
--- a/lib/public/Files/SimpleFS/InMemoryFile.php
+++ b/lib/public/Files/SimpleFS/InMemoryFile.php
@@ -127,6 +127,13 @@ class InMemoryFile implements ISimpleFile {
}
/**
+ * {@inheritDoc}
+ */
+ public function getExtension(): string {
+ return \pathinfo($this->name, PATHINFO_EXTENSION);
+ }
+
+ /**
* Stream reading is unsupported for in memory files.
*
* @throws NotPermittedException