fix: php.rs olvidado.
This commit is contained in:
parent
a40ca99a3b
commit
8c03e6420c
|
@ -0,0 +1,42 @@
|
|||
use std::io::Write;
|
||||
fn execute_php(command: &str, arguments: &[&str]) -> String {
|
||||
let mut execute_array: Vec<&str> = Vec::new();
|
||||
execute_array.extend(&["-r", &command, "--"]);
|
||||
execute_array.extend(arguments);
|
||||
let output = std::process::Command::new("php")
|
||||
.args(execute_array)
|
||||
.output()
|
||||
.expect("");
|
||||
let mut buff_stderr = std::io::BufWriter::new(std::io::stderr());
|
||||
buff_stderr
|
||||
.write(&output.stderr)
|
||||
.expect("Unable to write to stderr.");
|
||||
buff_stderr.flush().expect("Unable to flush stderr.");
|
||||
return String::from_utf8(output.stdout).expect("Unable to parse php response");
|
||||
}
|
||||
|
||||
pub fn ls(path: &str, user: &str, nextcloud_location: &str) {
|
||||
let php_script: String = [
|
||||
"define('OC_CONSOLE', 1);",
|
||||
"$user = $argv[1];",
|
||||
"$nextcloud_location = $argv[2];",
|
||||
"$path = $argv[3];",
|
||||
"include $nextcloud_location . '/lib/base.php';",
|
||||
"use Symfony\\Component\\Console\\Application as SymfonyApplication;",
|
||||
"use \\OC\\Files\\View;",
|
||||
"$application = new SymfonyApplication(
|
||||
\\OC::$server->getThemingDefaults()->getName(),
|
||||
\\OC_Util::getVersionString()
|
||||
);",
|
||||
"\\OC_Util::setupFS($user);",
|
||||
"$view = new View('/'. $user . '/files');",
|
||||
"foreach ($view->getDirectoryContent($path) as $node) {
|
||||
print $node->getName() . \"\\n\";
|
||||
}",
|
||||
]
|
||||
.join("\n");
|
||||
eprintln!(
|
||||
"{}",
|
||||
execute_php(&php_script, &[user, nextcloud_location, path])
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue