1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- class Filesystem extends Auth {
-
- protected function __construct() {
- parent::__construct();
- }
-
- /* deleteDir - loesche ein Verzeichnis rekursiv
- * Rueckgabewerte:
- * 0 - alles ok
- * -1 - kein Verzeichnis
- * -2 - Fehler beim Loeschen
- * -3 - Ein Eintrag eines Verzeichnisses war keine Datei und kein Verzeichnis und
- * kein Link
- */
- protected function deleteDir ($path) {
- if (!is_dir ($path))return -1;
- $dir = @opendir ($path);
- if (!$dir)return -2;
- while (($entry = @readdir($dir)) !== false) {
- if ($entry == '.' || $entry == '..') continue;
- if (is_dir ($path.'/'.$entry)) {
- $res = $this->deleteDir($path.'/'.$entry);
- if ($res == -1) {
- @closedir ($dir);
- return -2;
- } else if ($res == -2) {
- @closedir ($dir);
- return -2;
- } else if ($res == -3) {
- @closedir ($dir);
- return -3;
- } else if ($res != 0) {
- @closedir ($dir);
- return -2;
- }
- } else if (is_file ($path.'/'.$entry) || is_link ($path.'/'.$entry)) {
- $res = @unlink ($path.'/'.$entry);
- if (!$res) {
- @closedir ($dir);
- return -2;
- }
- } else {
- @closedir ($dir);
- return -3;
- }
- }
- @closedir ($dir);
- $res = @rmdir ($path);
- if (!$res) return -2;
- return 0;
- }
-
- static public function standardDirFormat() {
- $args = func_get_args();
- $i=0;
- $path="";
- foreach($args as $piece) {
- if($i>0 && (substr($piece,0,2) == "./" || substr($piece,0,2) == ".\\")) {
- $path .= substr($piece,2);
- }else if($i==0) {
- $path .= $piece;
- }
- }
- if(substr($path, -1) != "/" && substr($path, -1) != "\\") $path = $path . DIRECTORY_SEPARATOR;
- else $path = $path;
- return $path;
- }
- }
- ?>
|