Exemplo n.º 1
0
 public function testFilesystem()
 {
     isFileEq(__FILE__, __FILE__);
     is(openFile(__FILE__), openFile(__FILE__));
     isFile(__FILE__);
     isDir(__DIR__);
     isNotFile(__DIR__);
     isNotFile(__FILE__ . '.qwerty');
     isNotDir(__FILE__);
     isNotDir(__DIR__ . '/qwerty');
 }
Exemplo n.º 2
0
/**
* function to manage the loading of modules
* @param: $path - path to the modules, on first run, this is not supplied
* so the default is taken $modules_path
* @param: $count - number of times the function has recalled itself
*/
function loadModules($path,$count) {
	//load globals
	global $modules_path;
	//path to the file
	$filePath=0;
	$filePath=($path?$path:$modules_path);
	//increment counter
	$count+=1;
	//loop only if
	if($handle=opendir($filePath)) {
		//loop through directory
		while(false!==($file=readdir($handle))) {
			if($file!="." && $file!="..") {
				//if count<2, proceed at will
				if($count<2) {
					if(isDir($filePath,$file)) {
						//loop through directory
						loadModules($filePath."$file/",$count);
					} else {
						//include module file
						include_once $filePath."$file";
					}
				} else {
					//only inlcude what's inside directory classes
					if(isDir($filePath,$file) && $file=="classes") {
						//loop through directory only if it's called classes
						loadModules($filePath."$file/",$count);
					} else if(!isDir($filePath,$file)){
						//include module file
						include_once $filePath."$file";
					}
				}
			}
		}
		closedir($handle);
	}
}
Exemplo n.º 3
0
function listdir($start_dir = '.')
{
    $files = array();
    if (isDir($start_dir)) {
        $fh = opendir($start_dir);
        while (($file = readdir($fh)) !== false) {
            # loop through the files, skipping . and .., and recursing if necessary
            if (strcmp($file, '.') == 0 || strcmp($file, '..') == 0) {
                continue;
            }
            $filepath = $start_dir . '/' . $file;
            if (isDir($filepath)) {
                $files = array_merge($files, listdir($filepath));
            } else {
                array_push($files, $filepath);
            }
        }
        closedir($fh);
    } else {
        # false if the function was called with an invalid non-directory argument
        $files = false;
    }
    return $files;
}
Exemplo n.º 4
0
 // this is testing for whether the ftp_rawlist starts with the dir total
 // or a directory/file, $index is the index for the files[] array
 if (count(explode(" ", $files[0])) == 2) {
     $index = 1;
 } else {
     $index = 0;
 }
 // for each file, link, or directory listed in the current directory
 // seperate the raw data into readable variables
 for ($indexNew = 0; $index < count($files); $index++, $indexNew++) {
     $data[$indexNew] = remove_ws($files[$index]);
 }
 // sort through directory listing
 for ($index = 0; $index < count($data); $index++) {
     // put directories into a list
     if (isDir($data[$index][0])) {
         $dir_list[count($dir_list)] = $data[$index];
     } else {
         if (isLink($data[$index][0])) {
             // get the links name, and what it points at
             list($name, $addr) = split(" -> ", $data[$index][8]);
             // overwrite the link name so that it just has the name to be displayed
             $data[$index][8] = $name;
             // store the link pointer as the whole path
             if (substr($addr, 0, 1) != '/') {
                 $addr = $sess_Data["dir"] . "/" . $addr;
             }
             // attempt to change to the link, if it fails it is a file
             // this needs work, what if you don't have permission
             $RESULT = @ftp_chdir($fp, $addr);
             if ($RESULT) {
Exemplo n.º 5
0
function getdirname($base)
{
    // count underscores in filename
    $numsep = substr_count($base, "_");
    if (!$numsep) {
        continue;
    }
    // break filename on underscores
    $allstr = explode("_", $base);
    if ($numsep == 1) {
        // two part name- dir must be parts 0
        $seq = $allstr[1];
        $dirname = $allstr[0];
    } elseif ($numsep == 2) {
        // three part name- dir must be parts 0,1
        $seq = $allstr[2];
        $dirname = $allstr[0] . '_' . $allstr[1];
    } elseif ($numsep == 3) {
        $seq = $allstr[3];
        // four part name- dir must be parts 0,1,2
        $dirname = $allstr[0] . "_" . $allstr[1] . "_" . $allstr[2];
    }
    // convert seq to integer
    $seq = $seq * 1;
    if ($seq >= 1 && $seq <= 2000) {
        print "seq = {$seq}\n";
    }
    // check for dir already there
    $seqdir = $dirname . '/' . $seq;
    if (!isDir($seqdir)) {
        mkdir($seqdir);
        print "made seqdir= {$seqdir} \n";
    }
    return $dirname;
}
Exemplo n.º 6
0
function installed()
{
    $installPath = config()->getPath();
    return isDir("{$installPath}/releases", true) && isDir("{$installPath}/data", true);
}
Exemplo n.º 7
0
function is_dir_tree($dir)
{
    if ($dh = @opendir($dir)) {
        if ($dir == '/') {
            $dir = "";
        }
        while (false !== ($file = @readdir($dh))) {
            if (isDir($dir . '/' . $file) && $file[0] != ".") {
                @closedir($dh);
                return true;
            }
        }
    }
    @closedir($dh);
    return false;
}
Exemplo n.º 8
0
Arquivo: i.php Projeto: xudihui/cases
/**
 * 获取文件列表
 * 
 * @param string  $dir  欲读取的目录路径
 * @param boolean $mode 0:读取全部;1:仅读取文件;2:仅读取目录
 * @return array
 */
function ReadFolder($dir, $mode = 0)
{
    //如果打开目录句柄失败,则输出空数组
    if (!($handle = @opendir($dir))) {
        return array();
    }
    //定义文件列表数组
    $files = array();
    //遍历目录句柄中的条目
    while (false !== ($file = @readdir($handle))) {
        //跳过本目录以及上级目录
        if ('.' === $file || '..' === $file) {
            continue;
        }
        //是否仅读取目录
        if ($mode === 2) {
            if (isDir($dir . '/' . $file)) {
                $files[] = $file;
            }
            //是否仅读取文件
        } elseif ($mode === 1) {
            if (isFile($dir . '/' . $file)) {
                $files[] = $file;
            }
            //读取全部
        } else {
            $files[] = $file;
        }
    }
    //关闭打开的目录句柄
    @closedir($handle);
    //输出文件列表数组
    return $files;
}
Exemplo n.º 9
0
function getFoldersList()
{
    $folders = array();
    $files_dir = getDirList();
    foreach ($files_dir as $key => $value) {
        if (isDir($value)) {
            $folders[$key] = $value;
        }
    }
    return $folders;
}