feat BlueprintAdminLibrary
, BlueprintClientLibrary
, BlueprintConsoleLibrary
: rewrite fileRead() to no longer use shell commands caused by tech-debt
This commit is contained in:
parent
b1fe15a628
commit
dac362dad5
3 changed files with 27 additions and 6 deletions
|
@ -101,12 +101,19 @@ class BlueprintAdminLibrary
|
|||
*
|
||||
* @param string $path Path to file
|
||||
* @return string File contents
|
||||
* @throws string Errors encountered by `cat` shell utility
|
||||
* @throws string File cannot be read or found
|
||||
*
|
||||
* [BlueprintExtensionLibrary documentation](https://blueprint.zip/docs/?page=documentation/$blueprint)
|
||||
*/
|
||||
public function fileRead($path) {
|
||||
return shell_exec("cat ".escapeshellarg($path).";");
|
||||
if (!file_exists($path)) {
|
||||
return "File not found: " . $path;
|
||||
}
|
||||
if (!is_readable($path)) {
|
||||
return "File is not readable: " . $path;
|
||||
}
|
||||
|
||||
return file_get_contents($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,12 +58,19 @@ class BlueprintClientLibrary
|
|||
*
|
||||
* @param string $path Path to file
|
||||
* @return string File contents
|
||||
* @throws string Errors encountered by `cat` shell utility
|
||||
* @throws string File cannot be read or found
|
||||
*
|
||||
* [BlueprintExtensionLibrary documentation](https://blueprint.zip/docs/?page=documentation/$blueprint)
|
||||
*/
|
||||
public function fileRead($path) {
|
||||
return shell_exec("cat ".escapeshellarg($path).";");
|
||||
if (!file_exists($path)) {
|
||||
return "File not found: " . $path;
|
||||
}
|
||||
if (!is_readable($path)) {
|
||||
return "File is not readable: " . $path;
|
||||
}
|
||||
|
||||
return file_get_contents($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,12 +58,19 @@ class BlueprintConsoleLibrary
|
|||
*
|
||||
* @param string $path Path to file
|
||||
* @return string File contents
|
||||
* @throws string Errors encountered by `cat` shell utility
|
||||
* @throws string File cannot be read or found
|
||||
*
|
||||
* [BlueprintExtensionLibrary documentation](https://blueprint.zip/docs/?page=documentation/$blueprint)
|
||||
*/
|
||||
public function fileRead($path) {
|
||||
return shell_exec("cat ".escapeshellarg($path).";");
|
||||
if (!file_exists($path)) {
|
||||
return "File not found: " . $path;
|
||||
}
|
||||
if (!is_readable($path)) {
|
||||
return "File is not readable: " . $path;
|
||||
}
|
||||
|
||||
return file_get_contents($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue