Browse Source

Repositories: scan_dir, file_get_contents, file_put_contents

master
parent
commit
8304df8c84
  1. 12
      src/RepositoryDir.php
  2. 19
      src/RepositoryGit.php

12
src/RepositoryDir.php

@ -37,4 +37,16 @@ class RepositoryDir extends RepositoryBase {
return $data;
}
function scandir($path="") {
return scandir("{$this->path}/{$path}");
}
function file_get_contents ($file) {
return file_get_contents("{$this->path}/{$file}");
}
function file_put_contents ($file, $content) {
return file_put_contents("{$this->path}/{$file}", $content);
}
}

19
src/RepositoryGit.php

@ -36,4 +36,23 @@ class RepositoryGit extends RepositoryBase {
return $data;
}
function scandir($path="") {
if ($path !== '' && substr($path, -1) !== '/') {
$path .= '/';
}
$d = popen("cd " . escapeShellArg($this->path) . "; git ls-tree HEAD " . escapeShellArg($path), "r");
$ret = array();
while ($r = fgets($d)) {
$ret[] = substr($r, 53);
}
pclose($d);
return $ret;
}
function file_get_contents ($file) {
return shell_exec("cd " . escapeShellArg($this->path) . "; git show HEAD:" . escapeShellArg($file));
}
}
Loading…
Cancel
Save