Skip to content
Snippets Groups Projects
Commit 39b57f47 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

add filesystem fopen

parent 59662008
Branches
1 merge request!50add filesystem fopen
Pipeline #19641 passed with stage
in 30 seconds
......@@ -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);
}
......@@ -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 [];
......
......@@ -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));
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment