aliroDirectory Class Reference

List of all members.

Public Member Functions

 __construct ($path)
 listAll ($type='file', $recurse=false, $fullpath=false)
 soleDir ()
 deleteAll ()
 createFresh ()
 createIfNeeded ()
 listFiles ($pattern='', $type='file', $recurse=false, $fullpath=false)
 getSize ()

Private Attributes

 $path = ''


Detailed Description

Definition at line 275 of file aliroFileManager.php.


Constructor & Destructor Documentation

aliroDirectory::__construct ( path  ) 

Definition at line 278 of file aliroFileManager.php.

References $path.

00278                                         {
00279         $path = str_replace('\\', '/', $path);
00280         $this->path = ('/' == substr($path,-1)) ? $path : $path.'/';
00281     }


Member Function Documentation

aliroDirectory::listAll ( type = 'file',
recurse = false,
fullpath = false 
)

Definition at line 283 of file aliroFileManager.php.

Referenced by deleteAll(), and listFiles().

00283                                                                             {
00284         $results = array();
00285         if ($dir = @opendir($this->path)) {
00286             while ($file = readdir($dir)) {
00287                 if ($file == '.' OR $file == '..') continue;
00288                 if (is_dir($this->path.$file)) {
00289                     if ($recurse) {
00290                         $subdir = new aliroDirectory($this->path.$file);
00291                         $results = array_merge($results, $subdir->listAll($type, $recurse, $fullpath));
00292                         unset($subdir);
00293                     }
00294                     if ($type == 'file') continue;
00295                 }
00296                 elseif ($type == 'dir') continue;
00297                 if ($fullpath) $results[] = $this->path.$file;
00298                 else $results[] = $file;
00299             }
00300             closedir($dir);
00301         }
00302         return $results;
00303     }

aliroDirectory::soleDir (  ) 

Definition at line 305 of file aliroFileManager.php.

00305                                {
00306         $found = '';
00307         if ($dir = @opendir($this->path)) {
00308             while ($file = readdir($dir)) {
00309                 if ($file == '.' OR $file == '..') continue;
00310                 if (is_dir($this->path.$file)) {
00311                     if ($found) return '';
00312                     else $found = $file;
00313                 }
00314                 else return '';
00315             }
00316             closedir($dir);
00317         }
00318         return $found;
00319     }

aliroDirectory::deleteAll (  ) 

Definition at line 321 of file aliroFileManager.php.

References aliroFileManager::getInstance(), and listAll().

Referenced by createFresh().

00321                                  {
00322         if (!file_exists($this->path)) return;
00323         $subdirs = $this->listAll ('dir', false, true);
00324         foreach ($subdirs as $subdir) {
00325             $subdirectory = new aliroDirectory($subdir);
00326             $subdirectory->deleteAll();
00327             unset($subdirectory);
00328         }
00329         $filemanager = aliroFileManager::getInstance();
00330         $files = $this->listAll ('file', false, true);
00331         foreach ($files as $file) $filemanager->deleteFile($file);
00332         $filemanager->deleteDirectory($this->path);
00333     }

aliroDirectory::createFresh (  ) 

Definition at line 335 of file aliroFileManager.php.

References deleteAll(), and aliroFileManager::getInstance().

00335                                    {
00336         $this->deleteAll();
00337         $filemanager = aliroFileManager::getInstance();
00338         $filemanager->createDirectory($this->path);
00339         return true;
00340     }

aliroDirectory::createIfNeeded (  ) 

Definition at line 342 of file aliroFileManager.php.

References aliroFileManager::getInstance().

00342                                       {
00343         if (!file_exists($this->path)) {
00344             $filemanager = aliroFileManager::getInstance();
00345             $filemanager->createDirectory($this->path);
00346         }
00347     }

aliroDirectory::listFiles ( pattern = '',
type = 'file',
recurse = false,
fullpath = false 
)

Definition at line 349 of file aliroFileManager.php.

References listAll().

Referenced by getSize().

00349                                                                                            {
00350         $results = array();
00351         $all = $this->listAll($type, $recurse, $fullpath);
00352         foreach ($all as $file) {
00353             $name = basename($file);
00354             if ($pattern AND !preg_match( "/$pattern/", $name )) continue;
00355             if (($name != 'index.html') AND ($name[0] != '.')) $results[] = $file;
00356         }
00357         return $results;
00358     }

aliroDirectory::getSize (  ) 

Definition at line 360 of file aliroFileManager.php.

References listFiles().

00360                                {
00361         $totalsize = 0;
00362         $files = $this->listFiles();
00363         foreach ($files as $file) $totalsize += filesize($this->path.$file);
00364         return $totalsize;
00365     }


Member Data Documentation

aliroDirectory::$path = '' [private]

Definition at line 276 of file aliroFileManager.php.

Referenced by __construct().


The documentation for this class was generated from the following file:

Generated on Thu Apr 17 13:03:29 2008 for ALIRO by  doxygen 1.5.5