Пример #1
0
function copyFiles($sd, $dd)
{
    global $fs;
    foreach ($fs->ls($sd) as $fn) {
        $sfp = PathUtil::rel($sd, $fn);
        $dfp = PathUtil::rel($dd, $fn);
        //print "copy $sfp $dfp<BR>\n";
        if ($fs->isDir($sfp)) {
            copyFiles($sfp, $dfp);
        } else {
            $fs->setContent($dfp, $fs->getContent($sfp));
        }
    }
}
Пример #2
0
function getDirInfo2($path, $base)
{
    global $fs;
    $dst = array();
    if (!$fs->exists($path)) {
        return $dst;
    }
    $files = $fs->ls($path);
    foreach ($files as $e) {
        $fp = PathUtil::rel($path, $e);
        if ($fs->isDir($fp)) {
            $dst += getDirInfo2($fp, $base);
        } else {
            $dst[PathUtil::relPath($fp, $base)] = $fs->getMetaInfo($fp);
            //$dst+=array( PathUtil::relPath( $fp,$base ) => $fs->getMetaInfo($fp) );
        }
    }
    return $dst;
}
Пример #3
0
 public function ls($path)
 {
     $this->check($path, Permission::LS);
     $res = array();
     if ($handle = opendir($this->resolve($path))) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry != "." && $entry != "..") {
                 if ($this->isDir(PathUtil::rel($path, $entry))) {
                     $entry = $entry . PathUtil::SEP;
                 }
                 array_push($res, $entry);
             }
         }
         closedir($handle);
     } else {
         $this->notFound($path);
     }
     return $res;
 }
Пример #4
0
require_once "php/auth.php";
require_once "php/ErrorHandler.php";
$fs = Auth::getFS();
//new NativeFS("../fs");
$json = new Services_JSON();
header("Content-type: text/json");
if (!isset($_POST["base"])) {
    die("Specify base");
}
$base = $_POST["base"];
if (!isset($_POST["data"])) {
    die("Specify data");
}
$data = $json->decode($_POST["data"]);
foreach ($data as $path => $cont) {
    //print "cont $cont";
    $fp = PathUtil::rel($base, $path);
    if (isset($cont["trashed"])) {
        if ($fs->exists($fp)) {
            $fs->rm($fp);
        }
    } else {
        $fs->setContent($fp, $cont["text"]);
        $fs->setMetaInfo($fp, array("lastUpdate" => $cont["lastUpdate"]));
    }
}
//header("Content-type: text/plain");
//print "OK";
require_once "php/getDirInfoLib.php";
print $json->encode(getDirInfo($base, $base));
//print $_POST["data"];
Пример #5
0
 public function rel($r)
 {
     return $this->resolve(PathUtil::rel($this->path(), $r));
 }