コード例 #1
0
ファイル: bootstrapper.php プロジェクト: asteig/rabidcore
/**
 * This could go into the File class, but then how would Env be able to find
 * File.php?
 */
function searchDir($class, $dirname, $recursive = true)
{
    $dirname = $dirname . '/';
    $dir = dir($dirname);
    $classFile = $dirname . $class . ".php";
    if (file_exists($classFile)) {
        return $classFile;
    }
    while (false !== ($cdir = $dir->read())) {
        if (!preg_match('/^\\./', $cdir)) {
            $node = null;
            if (is_dir($dirname . $cdir) && $recursive == true) {
                $node = searchDir($class, $dirname . $cdir . "/");
            }
            if ($node) {
                return $node;
            }
        }
    }
    $dir->close();
    return false;
}
コード例 #2
0
                    $add = false;
                }
            }
            if ($fName == "..") {
                if ($p == $base_dir) {
                    $add = false;
                } else {
                    $add = true;
                }
                $tempar = explode("/", $fPath);
                array_splice($tempar, -2);
                $fPath = implode("/", $tempar);
                if (strlen($fPath) <= strlen($base_dir)) {
                    $fPath = "";
                }
            }
        }
        if ($fPath != "") {
            $fPath = substr($fPath, strlen($base_dir));
        }
        if ($add) {
            $contents[] = array("fPath" => $fPath, "fName" => $fName, "fType" => $fType);
        }
    }
    $p = strlen($p) <= strlen($base_dir) ? $p = "" : substr($p, strlen($base_dir));
    return array("contents" => $contents, "currentPath" => $p);
}
$p = isset($_POST["path"]) ? $_POST["path"] : "";
$f = isset($_POST["filter"]) ? $_POST["filter"] : "";
echo json_encode(searchDir("./", $p, $f, -1));
コード例 #3
0
ファイル: LfDealFile.php プロジェクト: HivenKay/ESalon
 static function getDir($dir)
 {
     $data = array();
     searchDir($dir, $data);
     return $data;
 }
コード例 #4
0
ファイル: index.php プロジェクト: suwenxiong/gophp
function getDir($dir, $prefix = false)
{
    $data = array();
    searchDir($dir, $data, $prefix);
    return $data;
}
コード例 #5
0
function getAllFiles($dir)
{
    $data = array();
    searchDir($dir, "", $data);
    return $data;
}