diff --git a/src/Storm/FileSystem/Abstract.php b/src/Storm/FileSystem/Abstract.php index 0f6c0f9db3e1df7e65356321a5e8936a8052fca9..9a50569848d4fa2a229e6fccd72378e5e8b05bdf 100644 --- a/src/Storm/FileSystem/Abstract.php +++ b/src/Storm/FileSystem/Abstract.php @@ -55,4 +55,7 @@ abstract class Storm_FileSystem_Abstract { abstract public function readfile(string $path); abstract public function mkdir($path); + + abstract public function fopen(string $filename, string $mode, bool $use_include_path=false, $context=null); + } diff --git a/src/Storm/FileSystem/Disk.php b/src/Storm/FileSystem/Disk.php index df973afd205ac2a9cd2500f66cd70175aeefd367..c9248e3a269850446c224c7176a3fc06a801829e 100644 --- a/src/Storm/FileSystem/Disk.php +++ b/src/Storm/FileSystem/Disk.php @@ -92,6 +92,14 @@ class Storm_FileSystem_Disk extends Storm_FileSystem_Abstract { } + public function fopen(string $filename, + string $mode, + bool $use_include_path=false, + $context=null) { + return fopen($filename, $mode, $use_include_path, $context); + } + + public function directoryNamesAt($path) { if (!file_exists($path) || !is_readable($path) ) return []; diff --git a/src/Storm/FileSystem/Volatile.php b/src/Storm/FileSystem/Volatile.php index 1ee0f509c41e250ba4685f177deff9ffca4cdc3d..c2efb0e8b01b8a9ebcbfccf7c36b8fb4c6ef4b43 100644 --- a/src/Storm/FileSystem/Volatile.php +++ b/src/Storm/FileSystem/Volatile.php @@ -147,6 +147,20 @@ class Storm_FileSystem_Volatile extends Storm_FileSystem_Abstract { } + public function fopen(string $filename, + string $mode, + bool $use_include_path=false, + $context=null) { + if (null === ($file_content = $this->fileGetContents($filename))) + return false; + + $content = fopen('php://memory', 'r+'); + fwrite($content, $file_content); + rewind($content); + return $content; + } + + public function asPath($path) { return (new Storm_FileSystem_Volatile_Path($path, $this->_current_directory)); }