aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPytal <24800714+Pytal@users.noreply.github.com>2022-03-07 11:38:23 -0800
committerGitHub <noreply@github.com>2022-03-07 11:38:23 -0800
commit232af474a87310e79ff188dbdb8c02e0764f5009 (patch)
tree0f0cd4d8c05bc1ab3a26e87fa52848ac6a633e71
parent9be87e6b257107d9dcb8a42695c34ccef5292286 (diff)
parent26e3bdfce3f84345ba23f5a464f06a9b66faf3ca (diff)
downloadnextcloud-server-232af474a87310e79ff188dbdb8c02e0764f5009.tar.gz
nextcloud-server-232af474a87310e79ff188dbdb8c02e0764f5009.zip
Merge pull request #31418 from nextcloud/enh/simple-file-extension
-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.php11
-rw-r--r--lib/public/Files/SimpleFS/InMemoryFile.php8
4 files changed, 36 insertions, 1 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..8f1921cb7cb 100644
--- a/lib/public/Files/SimpleFS/ISimpleFile.php
+++ b/lib/public/Files/SimpleFS/ISimpleFile.php
@@ -28,7 +28,11 @@ use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
/**
- * Interface ISimpleFile
+ * This interface allows to manage simple files.
+ *
+ * This interface must not be implemented in your application but
+ * instead should be used as a service and injected in your code with
+ * dependency injection.
*
* @since 11.0.0
*/
@@ -103,6 +107,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..590cb43e1d6 100644
--- a/lib/public/Files/SimpleFS/InMemoryFile.php
+++ b/lib/public/Files/SimpleFS/InMemoryFile.php
@@ -127,6 +127,14 @@ class InMemoryFile implements ISimpleFile {
}
/**
+ * {@inheritDoc}
+ * @since 24.0.0
+ */
+ public function getExtension(): string {
+ return \pathinfo($this->name, PATHINFO_EXTENSION);
+ }
+
+ /**
* Stream reading is unsupported for in memory files.
*
* @throws NotPermittedException