blueshoes php application framework and cms            core_file
[ class tree: core_file ] [ index: core_file ] [ all elements ]

Class: Bs_File

Source Location: /core/file/Bs_File.class.php

Class Overview

Bs_Object
   |
   --Bs_FileSystem
      |
      --Bs_File

* Represents a FILE (or a DIRECTORY?) as an Object


Author(s):

Version:

  • 4.3.$Revision: 1.2 $ $Date: 2003/10/29 17:48:37 $

Copyright:

  • blueshoes.org

Methods


Inherited Variables

Inherited Methods

Class: Bs_FileSystem

Bs_FileSystem::Bs_FileSystem()
* Constructor.
Bs_FileSystem::basename()
returns the base name of a path (filename).
Bs_FileSystem::getCwd()
Gets the current process working directory by using PHP's getcwd() and converting the result to our standard.
Bs_FileSystem::getFileAttr()
Return most of the file attribute info. (Should work with Windows too).
Bs_FileSystem::getFileExtension()
Get the file extension from a path.
Bs_FileSystem::getFileName()
Bs_FileSystem::getFullPath()
returns the directory or file that this object (subclassed file or dir object) is looking at.
Bs_FileSystem::getPathStem()
Get the stem part of a path.
Bs_FileSystem::getRealPath()
Returns canonicalized real pathname *with* ending '/' if it's a dir AND(!) checks for existence!
Bs_FileSystem::getRealPathSplit()
Returns a splited canonicalized real pathname *with* ending '/' if it's a dir.
Bs_FileSystem::getWithoutFileExtension()
returns the filename without the file extension.
Bs_FileSystem::isLink()
tells wheter the current file/path (or $fullPath) is a link or not.
Bs_FileSystem::isValidFilename()
windows filename and dirname (tested on winnt 4.0 german)
Bs_FileSystem::isValidFullPath()
Bs_FileSystem::isValidPath()
Bs_FileSystem::makeValidFileName()
removes/replaces invalid characters in the filename specified.
Bs_FileSystem::realPath()
Returns canonicalized real pathname *with* ending '/' if it's a dir.
Bs_FileSystem::realPathSplit()
Returns a splited canonicalized real pathname *with* ending '/' if it's a dir.
Bs_FileSystem::setFullPath()
Set our view to the directory or file passed by '$workingDir'.
Bs_FileSystem::standardizePath()
The path format for input may be windows-like with '\' backslashes.

Class: Bs_Object

Bs_Object::Bs_Object()
Bs_Object::getErrors()
Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.
Bs_Object::getLastError()
Basic error handling: Get last error string from the global Bs_Error-error stack.
Bs_Object::getLastErrors()
Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().
Bs_Object::persist()
Persists this object by serializing it and saving it to a file with unique name.
Bs_Object::setError()
Basic error handling: Push an error string on the global Bs_Error-error stack.
Bs_Object::toHtml()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::toString()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::unpersist()
Fetches an object that was persisted with persist()

Class Details

[line 28]
* Represents a FILE (or a DIRECTORY?) as an Object

Class File is an Object representation of a file OR directory. NOTE I : A directory is to be seen as a file; a special file, but still, a file. NOTE II: Some successful test were made on Windows(c) 2000 and it seams as if backslashes '\' in the path work as well as UNIX like forslashes '/'. ERGO: Use forslashes '/'. Because it then will work on both systems and '\' could be easily misinterpreted as escape char.

>> YES, windows will always understand '/' while unix doesn't accept '\'. --andrej




Tags:

version:  4.3.$Revision: 1.2 $ $Date: 2003/10/29 17:48:37 $
copyright:  blueshoes.org
author:  andrej arn <at blueshoes dot org>, Sam Blum <sam at blueshoes dot org>
todo:  Slash-handling (espacilly the '/' and '\' distinction)
todo:  Things like open, close, readLine, read, create, write, append


[ Top ]


Class Methods


constructor Bs_File [line 35]

Bs_File Bs_File( [$fullpath $fullPath = ''])

Constructor.

Fullpath may be of any format. E.g. dir, dir/, dir/file, ./dir/dir/file, ... NOTE: $fullPath should be a valid path to a file or dir. It will otherwise be ''.




Parameters:

$fullpath   $fullPath   string. A valid path to a file or dir.

[ Top ]

method append [line 287]

void append( mixed $string)



[ Top ]

method cp [line 46]

void cp( )

* Copy the current file.

overloading used here, for details check _cp2() and _cp3().




Tags:

access:  public


[ Top ]

method create [line 151]

void create( mixed $fullPath)



[ Top ]

method exclusiveWrite [line 239]

bool exclusiveWrite( string $string, string $fullPath)

Exclusive file write.

Try to get hold of a file exclusively and overwrite it with the passed data.




Tags:

return:  TRUE on success, FALSE on failure. (Use getLastError()).
see:  Bs_File::onewayWrite(), Bs_File::onewayAppend()


Parameters:

string   $string   the data you want to write to the file.
string   $fullPath   default is NULL. if used, this method is used static.

[ Top ]

method move [line 125]

bool move( string $oldFullPath, string $newFullPath, [string $overwrite = TRUE])

this is basically rename() from PHP but in addition can deal with overwriting files.

PHP stops and returns FALSE when the destination already exists.




Parameters:

string   $oldFullPath  
string   $newFullPath  
string   $overwrite  

[ Top ]

method onewayAppend [line 205]

bool onewayAppend( string $string, [string $fullPath = NULL])

appends $string at the end of the file.

if it doesn't exist it will be created. it's called oneway because the file is opened, the string is written, and then the file is closed immediatly.




Tags:

return:  true on success, false on failure.
see:  Bs_File::onewayWrite(), Bs_File::exclusiveWrite()


Parameters:

string   $string   the data you want to write to the file.
string   $fullPath   default is NULL. if used, this method is used static.

[ Top ]

method onewayWrite [line 190]

bool onewayWrite( string $string, [string $fullPath = NULL])

writes $string to the file. if the file already exists all content will be overwritten.

if it doesn't exist it will be created. it's called oneway because the file is opened, the string is written, and then the file is closed immediatly.




Tags:

return:  true on success, false on failure.
see:  Bs_File::onewayAppend(), Bs_File::exclusiveWrite()


Parameters:

string   $string   the data you want to write to the file.
string   $fullPath   default is NULL. if used, this method is used static.

[ Top ]

method readAll [line 167]

string readAll( [string $fullPath = NULL])



Tags:

return:  the whole file content.
todo:  finish code
throws:  FALSE
deprecated:  

!!!!!!!!!!! deprecated, use join('', file($fullPath)) or get_file_contents($fullPath) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

reads everything from the file and returns it.



Parameters:

string   $fullPath   default is NULL. if used, this method is used static.

[ Top ]

method rm [line 143]

bool rm( )

removes this file (rm).

please don't add synonyms like remove(), delete(), unlink() etc.




Tags:

access:  public


[ Top ]

method toHtml [line 311]

html toHtml( )

*

Dump file attributes as HTML String




Tags:

access:  public


Overrides Bs_Object::toHtml() (Dumps the content of this object to a string using PHP's var_dump().)

[ Top ]

method toString [line 296]

string toString( [mixed $cr = "\n"])

*

Dump file attributes as String




Tags:

access:  public


Overrides Bs_Object::toString() (Dumps the content of this object to a string using PHP's var_dump().)

[ Top ]

method write [line 284]

void write( mixed $string)



Tags:



[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:09:01 +0100 by phpDocumentor 1.2.3