BlueShoes Application Framework made with PHP http://www.blueshoes.org/


Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: C:/usr/local/lib/php/blueshoes-4.2/core/file/Bs_Dir.class.php
BlueShoes Application Framework - file

Bs_Dir

Bs_Object
   |
  +-- Bs_FileSystem
     |
    +-- Bs_Dir

Directory Class.

 

private class Bs_Dir extends Bs_FileSystem

Directory Class.
dependencies: bs_filesystem,bs_file (may be used for returning in getFileList())

Authors,
Version4.0-$id$
Copyrightblueshoes.org

 

Methods inherited from Bs_FileSystem

bs_filesystem, getfileattr, standardizepath, getcwd, getrealpath, realpath, getrealpathsplit, realpathsplit, getfullpath, getpathstem, getfilename, getfileextension, basename, isvalidfilename, isvalidpath, isvalidfullpath, islink, clearstatcache, move

Methods inherited from Bs_Object

isex, isexception, tostring, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean

Public Method Summary

void

Bs_Dir([ string $workingDir ])

Constructor.
bool

setFullPath(string $workingDir)

Set our view to the directory passed by '$workingDir'.Warning: documentation is missing.
bool

mkpath(string $path)

creates the given path, not just the last directory.
void

getFileList([ array $params ])

Get a list of files and dirs.
bool

emptyDir([ string $recursive, string $regExp ])

removes files from the directory. keeps the directory.

Private Method Summary

boolean

_open()

Open a PHP's pseudo-Directory-Object used to scan the file system.
void

_close()

Try to close the PHP's pseudo-Directory-Object used to scan the file system
void

destruct()

Warning: documentation is missing.
void

dir()

Warning: documentation is missing.
void

clearCache()

Warning: documentation is missing.
void

getFreeDiskSpace()

Warning: documentation is missing.
void

rm()

Warning: documentation is missing.
void

isEmpty()

Warning: documentation is missing.
void

cp()

Warning: documentation is missing.
void

mv()

Warning: documentation is missing.
void

create()

Warning: documentation is missing.
void

search()

Warning: documentation is missing.
void

searchAndReplace()

Warning: documentation is missing.

Fields inherited from Bs_FileSystem

$_lastfetchedpath, $_bs_system, $_fullpath, $_lastfetchedfileattr

Private Field Summary

unknown

$_dirObj

PHP's pseudo-Directory-Object used to scan the file system.

Private Constant Summary

BS_DIR_VERSION >>4.0.$x$<< Warning: documentation is missing.
BS_DIR_UNLIM_DEPTH >>-99<< Warning: documentation is missing.

Public Method Details

Bs_Dir

public void Bs_Dir( [ string $workingDir ] )

  Constructor.
NOTE: Fullpath may be of any format. E.g. dir, dir/, dir/file, ./dir/dir/file, /dir ...crap is: if setFullPath in here fails, then you won't know. so if you want to be surethen you better call the constructor without params and then do setFullPath() yourself.

Parameter
string $workingDir = >>NULL<<
(default=""). The path to a file or dir.
Returns void


setFullPath

public bool setFullPath( string $workingDir )

  Set our view to the directory passed by '$workingDir'.
If it's not the same dir as we were looking at before, free the resourcesand open a new view to the new dir.uses parent method.

Warning: documentation is missing.

Parameter
string $workingDir
a path
Returns bool


mkpath

public bool mkpath( string $path )

  creates the given path, not just the last directory.
example: mkpath('c:/your/path/whatever');even if c:\your already exists, but not path/whatever.you can use foreslashes or backslashes.got this from: http://www.php.net/manual/en/function.mkdir.phporiginal name: ForceDirectories()gjukema@jukeware.com 22-Jan-2001 06:40I needed a clean ForceDirectories function as used in Delphi. I grabbedthe source and converted to PHP. Just pass in a $path like"/tmp/dir1/dir2", and all "/tmp/dir1/dir2" will becreated if they don't exist - permissions allowed of coarse :).if the method fails, not everything (maybe parts) has been created.errors are suppressed.

Parameter
string $path
Returns bool

(TRUE on success, FALSE on failure.)


getFileList

public void getFileList( [ array $params ] )

  Get a list of files and dirs.
calls itself recursively.To set the start dir use the ['fullPath']. If omitted the start dir is the dirthis object is currently pointing at. ( See $this->setFullPath() )The other fields are all optional. See the defaults in the text below.

Parameter
array $params = >>array()<<
a hash than can have these elements:
-----------------------------------------------------------------------------------------------------
['fullPath'] => string Starting point. The absolute path. Default: $this->_fullPath
If *NOT* set we take the fullPath of this object (if given). Otherwise we throw an exception.
-----------------------------------------------------------------------------------------------------
['regFunction'] => ('ereg'|'preg_match') Default: 'ereg'.
You may set the PHP regex-function to use. Just pass function name as string.
-----------------------------------------------------------------------------------------------------
['regEx'] => regEx-string Default: '';
The regular expresion is matched with the found file names without path by default.
If you want the path to be part of the match used the next param ['regWhere'].
-----------------------------------------------------------------------------------------------------
['regWhere'] => ('file'|'dir') Default: 'file'.
See ['regEx'] above
file = use reg expression on file only
dir = use reg expression on whole path
-----------------------------------------------------------------------------------------------------
['depth'] => int Default: BS_DIR_UNLIM_DEPTH.
How many directory levels the Dir should follow.
0 = Do not follow any dir. (= Use only current dir given by the path).
n = Go max n levels in depth.
-----------------------------------------------------------------------------------------------------
['fileDirLink'] => hash of flags. Default: all flags are set to TRUE ('file'=>TRUE, 'dir'=>TRUE, 'filelink'=>TRUE, 'dirlink'=>TRUE)
Control if files and/or dirs are to be fetched.
! On iX mashines (NOT on Windows) you can also fetch file-LINKS and/or dir-LINKS.
E.g. passing $params['fileDirLink'] = array('dir'=>FALSE) would ignor dirs.
['fileDirLink']['file'] : real files ['fileDirLink']['dir'] : file links
['fileDirLink']['filelink'] : real dirs ['fileDirLink']['dirlink'] : dir links
-----------------------------------------------------------------------------------------------------
['followLinks'] => bool Default: FALSE (Only iX mashines NOT available on Windows)
-----------------------------------------------------------------------------------------------------
['sort'] => bool Default: FALSE
Sort the files and dirs that are returnd. You may wish to turn this feature
on but it will use CPU (Tested with 3000 files: With sort it's 4x slower)
-----------------------------------------------------------------------------------------------------
['returnType'] => ('fullpath'|'subpath'|'nested'|'fulldir/file'|'subdir/file'|'subdir/file2'|'object')
Default: 'fullpath'
Control how to format the return.
Sample: /root
------ +-/subdir <--- starting Dir
| + A.txt
| + B.txt
+--/emptydir

NOTE: return order is system dependent!! DON'T look at order !!

['fullpath'] : return a vector filled with fullPath's + files e.g.
[0] => '/root/subdir/'
[1] => '/root/subdir/A.txt'
[2] => '/root/subdir/B.txt'
[3] => '/root/subdir/emptydir/'
['subpath'] : return a vector filled with rel-paths (relative from the current path) to the files and dirs.
[0] => 'subdir/'
[1] => 'subdir/A.txt'
[2] => 'subdir/B.txt'
[3] => 'subdir/emptydir/'
['nested'] : return a nested hash. the key is always the fullpath, the value is false for files and a hash for dirs
['subdir'] => [A.txt] => FALSE
[B.txt] => FALSE
['emptydir'] => array()
['nested2'] : return a nested hash. the key is always the subpath, the value is false for files and a hash for dirs
['subdir'] => [0] => 'A.txt'
[1] => 'B.txt'
['emptydir'] => array()
['fulldir/file'] : return a vector filled with a 2-key hash : 'dir' and 'file'
[0] => ('dir'=>'/root/subdir/', 'file'=>'')
[1] => ('dir'=>'/root/subdir/', 'file'=>'A.txt')
[2] => ('dir'=>'/root/subdir/', 'file'=>'B.txt')
[3] => ('dir'=>'/root/subdir/emptydir/', 'file'=>'')
['subdir/file'] : return a vector filled with a 2-key hash : 'dir' and 'file'
[0] => ('dir'=>'subdir/', 'file'=>'')
[1] => ('dir'=>'subdir/', 'file'=>'A.txt')
[2] => ('dir'=>'subdir/', 'file'=>'B.txt')
[3] => ('dir'=>'subdir/emptydir/', 'file'=>'')
['subdir/file2'] : return a vector filled with a 2-key hash : 'dir' and 'file'
Same as ['subdir/file'] but when a dir is found, the last path part is stored in 'file' also.
[0] => ('dir'=>'', 'file'=>'subdir')
[1] => ('dir'=>'subdir/', 'file'=>'A.txt')
[2] => ('dir'=>'subdir/', 'file'=>'B.txt')
[3] => ('dir'=>'subdir/', 'file'=>'emptydir')
['object'] : return a vector holding objects of Bs_File and Bs_Dir
[0] => new Bs_Dir('/root/subdir/')
[1] => new Bs_File('/root/subdir/A.txt')
[2] => new Bs_File('/root/subdir/B.txt')
[3] => new Bs_Dir('/root/subdir/emptydir/')
Returns void

Throws exception

emptyDir

public bool emptyDir( [ string $recursive, string $regExp ] )

  removes files from the directory. keeps the directory.
links won't be followed, but deleted.$Bs_Dir->emptyDir() will give the same result as "rm *" in linux.

Parameter
string $recursive = >>FALSE,<<
(default is FALSE)
string $regExp = >>NULL<<
(if given then the files need to match (perl-style) regExp in order to be deleted.)
Returns bool

TRUE

Throws bs_exception

Private Method Details

_open

private boolean _open( )

  Open a PHP's pseudo-Directory-Object used to scan the file system.
closes a previously opened one before, no matter if this method succeeded or not.

Returns boolean

TRUE on success; FALSE otherwise

See Also dir()

_close

private void _close( )

  Try to close the PHP's pseudo-Directory-Object used to scan the file system

Returns void

See Also dir()

destruct

private void destruct( )

 

Warning: documentation is missing.

Returns void


dir

private void dir( )

 

Warning: documentation is missing.

Returns void


clearCache

private void clearCache( )

 

Warning: documentation is missing.

Returns void


getFreeDiskSpace

private void getFreeDiskSpace( )

 

Warning: documentation is missing.

Returns void


rm

private void rm( )

 

Warning: documentation is missing.

Returns void


isEmpty

private void isEmpty( )

 

Warning: documentation is missing.

Returns void


cp

private void cp( )

 

Warning: documentation is missing.

Returns void


mv

private void mv( )

 

Warning: documentation is missing.

Returns void


create

private void create( )

 

Warning: documentation is missing.

Returns void


search

private void search( )

 

Warning: documentation is missing.

Returns void


searchAndReplace

private void searchAndReplace( )

 

Warning: documentation is missing.

Returns void


Private Field Details

$_dirObj

private unknown $_dirObj

>><<

PHP's pseudo-Directory-Object used to scan the file system.


Private Constant Details

BS_DIR_VERSION

define( BS_DIR_VERSION, >>4.0.$x$<< )
Case: default: case sensitive



BS_DIR_UNLIM_DEPTH

define( BS_DIR_UNLIM_DEPTH, >>-99<< )
Case: default: case sensitive




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta