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_FileSystem.class.php
BlueShoes Application Framework - file

Bs_FileSystem

Bs_Object
   |
  +-- Bs_FileSystem

FileSystem

 

private class Bs_FileSystem extends Bs_Object

FileSystem
Basic filesystem class. gets extended by Bs_File and Bs_Dir.Based on this object we have a dir and file object:FileSystem|+-----+-------+Dir FileNOTE: The path format for input may be windows-like with '\' backslashes.(Even some PHP functions spit out that fomat on Winblows).BUT in all output we use iX path format with '/' forslash.Luckelly Winblows has no problem with this format.Main concept change !=====================This class will have no knowlege of a dir-possition given by paramters.It's an attribute for the Dir- and File-class. In this way all routinescan be looked as static. --sam 7.6.2001not all methods. for example not getFileAttr() because of $this->_lastFetchedPathwe'd need to work around that. 2001/10/04 --andrejIn reality, a dir is not much different from a file. Actually on unix a dir *is* a file.But because you usually do different stuff with them (files -> read|write) and directoriescan 'hold' subdirs and files, we separate them.So wath do Dir and File have in commen?iX (Unix) | Windows NTo Methods:move X | Xdelete X | Xrename X | Xo Touch:create time X | Xaccess time X | X // If it's a dir == create timemodify time X | X // If it's a dir == create timeo File Access:writeable X | Xreadable X | Xexecuteable X | ? 1*)hidden, archive - | X // We will ignor this oneso File Rightsowner X | ? 2*)group X | ? 2*)all X | ? 2*)o Ownershipowner X | ? 3*)group X | ? 3*)o Linkinghard/soft link X | - 4*)short cut - 4*)| X1*) How does windows react? TRUE if readable? dser2*) Windows hat directory sharing. Is that what we see? What about files?3*) How does windows react? Who's the owner?4*) A 'short cut' is normal files (like a batch file) and *NOT* a link!Ever looked at a 'short cut' in the Windows-'Command Promt' (DOS-window)?It's just a stupid normal file that ends with ".lnk". Any file ending with ".lnk"is look as a 'short cut' to Windows.Lets say we have a the 'short cut' foo.lnk that 'links' to a text file foo.txt.Now wath would you expect when you type:more foo.lnkIf it were a link you would expect the content of foo.txt. But *suprise* you'll geta dump of the binary foo.lnk file. *brrrr*It's realy stupid and cheap! I did it 10 years ago by writing a normal ".bat"-file (batch files)that switched to the right dir and called that program. The difference is that 'short cut'-filesare binary and therefore not editable in a text editor.That's way you only can have a 'short cut' to files (no dirs).MEMO: Lots of problems with php's filesystem functions when we're on a winblows box :(1) many methods just don't work - as the docu says2) many bugs listed at php.netno dependencies here.

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

 
Direct known subclasses: Bs_Dir, Bs_File

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_FileSystem()

Constructor.
void

getFileAttr([ string $path, string $clearCache ])

Return most of the file attribute info. (Should work with Windows too).
string

standardizePath(string $path)

The path format for input may be windows-like with '\' backslashes.
string

getCwd()

Gets the current process working directory by using PHP's getcwd() and
string

getRealPath([ string $path ])

Returns canonicalized real pathname *with* ending '/' if it's a dir
void

getRealPathSplit([ string $path ])

Returns a splited canonicalized real pathname *with* ending '/' if it's a dir.
void

realPathSplit(string $path)

Returns a splited canonicalized real pathname *with* ending '/' if it's a dir.
bool

setFullPath(string $workingDir)

Set our view to the directory or file passed by '$workingDir'.
string

getFullPath()

returns the directory or file that this object (subclassed file or dir object) is looking at.
string

getPathStem(string $path)

Get the stem part of a path.
string

getFileName(string $path)

Get the file name from a path.
string

getFileExtension([ string $fullPath ])

Get the file extension from a path.
string

basename(string $path)

returns the base name of a path (filename).
bool

isLink([ string $fullPath ])

tells wheter the current file/path (or $fullPath) is a link or not.

Private Method Summary

void

realpath( $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path)

Warning: documentation is missing.
void

isValidFileName( $fileName, string $system)

windows filename and dirname (tested on winnt 4.0 german)
void

isValidPath( $path, string $system)

void

isValidFullPath( $fullPath, string $system)

void

clearstatcache( $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $clearCache, $clearCache, $clearCache, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, string $path, string $clearCache)

Warning: documentation is missing.
void

move( $src, $dest)

Warning: documentation is missing.

Private Field Summary

string

$_lastFetchedPath

Used with $this->getFileInfo() as cach info.
unknown

$_Bs_System

string

$_fullPath

array

$_lastFetchedFileAttr

Private Constant Summary

BS_FILESYSTEM_VERSION >>4.0.$x$<< Warning: documentation is missing.

Public Method Details

Bs_FileSystem

public void Bs_FileSystem( )

  Constructor.

Returns void


getFileAttr

public void getFileAttr( [ string $path, string $clearCache ] )

  Return most of the file attribute info. (Should work with Windows too).
this function only gets called fromNOTE: Invoking the stat or lstat system call on most systems is quite expensive.Therefore, the result of the last call to many of the status functions inPHP are stored for use on the next such call using the same file/dir-name.If you wish to force a new status check, for instance if the file isbeing checked many times and may change or disappear, set the param '$clearCache'to TRUE to force a system reread.!!!This value is only cached for the lifetime of a single request.!!!

Parameter
string $path = >>''<<
string $clearCache = >>FALSE<<
see note above
Returns void

Throws FALSE if file does not exist
See Also clearstatcache()

standardizePath

public string standardizePath( string $path )

  The path format for input may be windows-like with '\' backslashes.
(Even some PHP functions spit out that fomat on Winblows).BUT in all output we use iX path format with '/' forslash.Luckelly Winblows has no problem with this format.

Parameter
string $path
Returns string

A stanadardized path with '/' instead of '\'


getCwd

public string getCwd( )

  Gets the current process working directory by using PHP's getcwd() and
converting the result to our standard.

Returns string

A path to the current working directory of the current process.


getRealPath

public string getRealPath( [ string $path ] )

  Returns canonicalized real pathname *with* ending '/' if it's a dir
AND(!) checks for existence!This method basically executes our Bs_FileSystem::getRealPathSplit() function and checks for fileexistens.Make On windows, something like 'c:/dir////dir2' is converted to 'c:\dir\dir2', but i want to haveit converted to 'c:/dir/dir2/'. I like to have foreslashes on all systems. And in this case,dir2 was a directory even if the trailing slash was missing. realPath() should come with theintelligence to add it if dir2 is not a file, imo.

Parameter
string $path = >>''<<
a path or a part of it
Returns string

the real path

Throws bool FALSE if the path does not exist
See Also Bs_FileSystem::getRealPathSplit(), Bs_FileSystem::realPath(), Bs_FileSystem::realPathSplit()

getRealPathSplit

public void getRealPathSplit( [ string $path ] )

  Returns a splited canonicalized real pathname *with* ending '/' if it's a dir.
AND(!) checks for existence!This method basically executes our Bs_FileSystem::getRealPathSplit() function and checks for fileexistens.returns a hash: ['pathRoot'] <- Things like '/', 'c:/', 'http://', 'ftp://'['pathCore'] <- e.g. 'path/to/a/subdir/'['file'] <- if a file was in the path find it here['tailDir'] <- for convinience the last dir of the ['pathCore'] e.g. 'subdir'['realPath'] <- for convinience ['pathRoot'] . ['pathCore'] . ['file'];

Parameter
string $path = >>''<<
a path or a part of it
Returns void

Throws bool FALSE if the path does not exist
See Also Bs_FileSystem::getRealPath(), Bs_FileSystem::realPath(), Bs_FileSystem::realPathSplit()

realPathSplit

public void realPathSplit( string $path )

  Returns a splited canonicalized real pathname *with* ending '/' if it's a dir.
No existence check!NOTE 1: No file systems checks are made! So path may or *may not* exsist!See Bs_FileSystem::getRealPathSplit()returns a hash: ['pathRoot'] <- Things like '/', 'c:/', 'http://', 'ftp://'['pathCore'] <- e.g. 'path/to/a/subdir/'['file'] <- if a file was in the path find it here['tailDir'] <- for convinience the last dir of the ['pathCore'] e.g. 'subdir'['realPath'] <- for convinience ['pathRoot'] . ['pathCore'] . ['file'];

Parameter
string $path
a path or a part of it
Returns void

See Also Bs_FileSystem::getRealPath(), Bs_FileSystem::getRealPathSplit(), Bs_FileSystem::realPath()

setFullPath

public bool setFullPath( string $workingDir )

  Set our view to the directory or file passed by '$workingDir'.

Parameter
string $workingDir
a path
Returns bool

TRUE if it's a new and valid dir, FALSE if it did not change.


getFullPath

public string getFullPath( )

  returns the directory or file that this object (subclassed file or dir object) is looking at.

Returns string


getPathStem

public string getPathStem( string $path )

  Get the stem part of a path.
Examples on Windows: (on *nix there is of course no drive prefix 'f:')"f:/dir 790/asdf/file.xyz.html" => "f:/dir 790/asdf/""f:\dir 790\asdf\file.xyz.html" => "f:/dir 790/asdf/""f:\dir 790\asdf/" => "f:/dir 790/asdf/""f:\dir 790\asdf" => "f:/dir 790/" <= even if asdf is a dir!! (see note II)NOTE I: PHP's dirname() doesn't return the trailing slash, but we do.NOTE II: This method doesn't try to check if the last part is a file or adir, when the trailing slash is not given. because the fullPathgiven doesn't need to exist (on this system)...so even if in 'c:/one/two' two is a directory, only 'c:/one/' willbe returned.

Parameter
string $path
a path
Returns string

the path (without filename)

Throws false

getFileName

public string getFileName( string $path )

  Get the file name from a path.

Parameter
string $path
filename and/or path
Returns string

the filename if found else ''


getFileExtension

public string getFileExtension( [ string $fullPath ] )

  Get the file extension from a path.
examples:'c:\myFile.php' -> 'php''c:\myFile.class.php' -> 'php''c:\myFile' -> '''c:\myFile.class.php.lnk' -> 'php' <= special case on winblows for linksmay be used without param, then it will be for the file/dir that iscurrently in use. otherwise it is used pseudostatic.

Parameter
string $fullPath = >>null<<
(a path to a dir or file on that machine)
Returns string

the file extension


basename

public string basename( string $path )

  returns the base name of a path (filename).
replacement to php's basename() function which sucks.The path you give is first standardized replace '\' with '/'see http://www.php.net/manual/en/function.basename.php

Parameter
string $path
Returns string


isLink

public bool isLink( [ string $fullPath ] )

  tells wheter the current file/path (or $fullPath) is a link or not.
uses php's is_link() on *nix and something handmade on winblows.may be used without param, then it will be for the file/dir that iscurrently in use. otherwise it is used pseudostatic.

Parameter
string $fullPath = >>null<<
(a path to a dir or file on that machine)
Returns bool


Private Method Details

realpath

private void realpath( $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path, $path )

 

Warning: documentation is missing.

Parameter
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.
$path
Warning: documentation is missing.