file.php File Reference

Go to the source code of this file.

Namespaces

namespace  cake

Functions

 __construct ($path, $create=false, $mode=0755)
 __destruct ()
 append ($data, $force=false)
 close ()
 create ()
 delete ()
 executable ()
 exists ()
 ext ()
Folder ()
 group ()
 info ()
 lastAccess ()
 lastChange ()
 md5 ($maxsize=5)
 name ()
 offset ($offset=false, $seek=SEEK_SET)
 open ($mode= 'r', $force=false)
 owner ()
 perms ()
 prepare ($data, $forceWindows=false)
 pwd ()
 read ($bytes=false, $mode= 'rb', $force=false)
 readable ()
 safe ($name=null, $ext=null)
 size ()
 writable ()
 write ($data, $mode= 'w', $force=false)

Variables

 $handle = null
 $lock = null
 $path = null


Function Documentation

__construct ( path,
create = false,
mode = 0755 
)

Constructor

Parameters:
string $path Path to file
boolean $create Create file if it does not exist (if true)
integer $mode Mode to apply to the folder holding the file private

Definition at line 94 of file file.php.

References $path, create(), exists(), Folder(), name(), pwd(), and safe().

Referenced by ThemeView::__construct(), MediaView::__construct(), XmlElement::__construct(), Xml::__construct(), XmlHelper::__construct(), JsHelper::__construct(), JavascriptHelper::__construct(), CakeSocket::__construct(), Overloadable2::__construct(), Overloadable::__construct(), DboSource::__construct(), DboMssql::__construct(), DataSource::__construct(), L10n::__construct(), HttpSocket::__construct(), Folder::__construct(), Flay::__construct(), SessionHelper::__construct(), __construct(), Permission::__construct(), AclNode::__construct(), Model::__construct(), Controller::__construct(), CakeSchema::__construct(), DbAcl::__construct(), and CakeErrorController::__construct().

__destruct (  ) 

Closes the current file if it is opened

private

Definition at line 117 of file file.php.

References close().

Referenced by Object::Object().

append ( data,
force = false 
)

Append given data string to this File.

Parameters:
string $data Data to write
string $force force the file to open
Returns:
boolean Success public

Definition at line 268 of file file.php.

References write().

close (  ) 

Closes the current file if it is opened.

Returns:
boolean True if closing was successful or file was already closed, otherwise false public

Definition at line 277 of file file.php.

Referenced by DataSource::__destruct(), __destruct(), read(), and HttpSocket::request().

create (  ) 

Creates the File.

Returns:
boolean Success public

Definition at line 126 of file file.php.

References exists().

Referenced by __construct(), SchemaShell::__create(), Scaffold::__scaffold(), Scaffold::__scaffoldSave(), Shell::_loadDbConfig(), AclShell::checkNodeType(), DboMssql::create(), AclShell::help(), ClassRegistry::init(), I18nShell::initdb(), AclShell::initdb(), AuthComponent::initialize(), AuthComponent::mapActions(), open(), SchemaShell::run(), and I18nShell::startup().

delete (  ) 

Deletes the File.

Returns:
boolean Success public

Definition at line 289 of file file.php.

References exists().

Referenced by DboMysqlBase::delete().

executable (  ) 

Returns true if the File is executable.

Returns:
boolean true if its executable, false otherwise public

Definition at line 438 of file file.php.

exists (  ) 

Returns true if the File exists.

Returns:
boolean true if it exists, false otherwise public

Definition at line 396 of file file.php.

Referenced by __construct(), ApiShell::__parseClass(), ExtractTask::__writeFiles(), ShellDispatcher::_initEnvironment(), create(), DboSource::defaultConditions(), delete(), ProjectTask::execute(), group(), AuthComponent::identify(), lastAccess(), lastChange(), open(), owner(), perms(), MagicDb::read(), size(), and SchemaShell::view().

ext (  ) 

Returns the File extension.

Returns:
string The File extension public

Definition at line 317 of file file.php.

References info().

Referenced by Router::__parseExtension(), View::_getLayoutFileName(), ScaffoldView::_getViewFileName(), View::_getViewFileName(), View::element(), HtmlHelper::meta(), Router::parse(), MagicDb::read(), safe(), and AuthComponent::startup().

& Folder (  ) 

Returns the current folder.

Returns:
Folder Current folder public

Definition at line 504 of file file.php.

Referenced by ShellDispatcher::__buildPaths(), __construct(), App::__find(), Configure::__list(), ViewTask::bake(), ProjectTask::bake(), PluginTask::bake(), ProjectTask::execute(), and SchemaShell::generate().

group (  ) 

Returns the File group.

Returns:
integer the Filegroup public

Definition at line 468 of file file.php.

References exists().

Referenced by TestSuiteShell::__canRun(), TestSuiteShell::__run(), TestSuiteShell::__setGetVars(), and Model::find().

info (  ) 

Returns the File extension.

Returns:
string The File extension public

Definition at line 302 of file file.php.

References name().

Referenced by ext(), name(), and CakeLog::write().

lastAccess (  ) 

Returns last access time.

Returns:
integer timestamp Timestamp of last access time public

Definition at line 480 of file file.php.

References exists().

lastChange (  ) 

Returns last modified time.

Returns:
integer timestamp Timestamp of last modification public

Definition at line 492 of file file.php.

References exists().

md5 ( maxsize = 5  ) 

Get md5 Checksum of file with previous check of Filesize

Parameters:
mixed $maxsize in MB or true to force
Returns:
string md5 Checksum See md5_file() public

Definition at line 366 of file file.php.

References size().

Referenced by __construct(), EmailComponent::__createBoundary(), Security::hash(), String::insert(), View::uuid(), and JavascriptHelper::writeEvents().

name (  ) 

Returns the File name without extension.

Returns:
string The File name without extension. public

Definition at line 332 of file file.php.

References info().

Referenced by TestSuiteShell::__canRun(), __construct(), Model::__construct(), Controller::__construct(), CakeSchema::__construct(), Model::__constructLinkedModel(), CookieComponent::__delete(), __destroy(), ExtractTask::__extract(), __gc(), Model::__generateAssociation(), ViewTask::__interactive(), PluginTask::__interactive(), ModelTask::__interactive(), DbConfigTask::__interactive(), DboMssql::__mapFields(), ApiShell::__parseClass(), __read(), Model::__saveMulti(), FormHelper::__selectOptions(), __write(), CookieComponent::__write(), CakeSchema::_build(), Component::_loadComponents(), View::_missingView(), View::_render(), AclBehavior::afterDelete(), AclBehavior::afterSave(), BakeShell::all(), DbConfigTask::bake(), TranslateBehavior::beforeFind(), DboMssql::buildColumn(), DboMssql::buildIndex(), FormHelper::button(), FormHelper::checkbox(), DboMssql::column(), FormHelper::create(), CookieComponent::destroy(), ModelTask::doAssociations(), View::error(), ErrorHandler::error(), ErrorHandler::error404(), Model::escapeField(), FormHelper::file(), FormHelper::hidden(), info(), Component::init(), ClassRegistry::init(), ConsoleShell::main(), HtmlHelper::meta(), DboPostgres::name(), AclNode::node(), AclBehavior::node(), Controller::paginate(), FormHelper::password(), pwd(), FormHelper::radio(), CookieComponent::read(), CakeSchema::read(), SchemaShell::run(), safe(), FormHelper::select(), CookieComponent::startup(), AuthComponent::startup(), SchemaShell::startup(), FormHelper::text(), FormHelper::textarea(), XmlNode::toArray(), and XmlNode::toString().

offset ( offset = false,
seek = SEEK_SET 
)

Sets or gets the offset for the currently opened file.

Parameters:
mixed $offset The $offset in bytes to seek. If set to false then the current offset is returned.
integer $seek PHP Constant SEEK_SET | SEEK_CUR | SEEK_END determining what the $offset is relative to
Returns:
mixed True on success, false on failure (set mode), false on failure or integer offset on success (get mode) public

Definition at line 207 of file file.php.

References open().

Referenced by ContainableBehavior::containments(), MagicFileResource::extract(), Model::find(), DboSource::generateAssociationQuery(), MagicFileResource::offset(), MagicFileResource::read(), DboMssql::renderStatement(), and DboFirebird::renderStatement().

open ( mode = 'r',
force = false 
)

Opens the current file with a given $mode

Parameters:
string $mode A valid 'fopen' mode string (r|w|a ...)
boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
Returns:
boolean True on success, false on failure public

Definition at line 145 of file file.php.

References create(), and exists().

Referenced by offset(), read(), and write().

owner (  ) 

Returns the File's owner.

Returns:
integer the Fileowner public

Definition at line 456 of file file.php.

References exists().

perms (  ) 

Returns the "chmod" (permissions) of the File.

Returns:
string Permissions for the file public

Definition at line 405 of file file.php.

References exists().

prepare ( data,
forceWindows = false 
)

Prepares a ascii string for writing fixes line endings

Parameters:
string $data Data to prepare for writing.
Returns:
string public

Definition at line 225 of file file.php.

pwd (  ) 

Returns the full path of the File.

Returns:
string Full path to file public

Definition at line 384 of file file.php.

References name().

Referenced by __construct(), ViewTask::bake(), SchemaShell::dump(), and MagicDb::read().

read ( bytes = false,
mode = 'rb',
force = false 
)

Return the contents of this File as a string.

Parameters:
string $bytes where to start
string $mode
boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
Returns:
mixed string on success, false on failure public

Definition at line 171 of file file.php.

References close(), and open().

Referenced by __initSession(), _checkValid(), TreeBehavior::beforeDelete(), SessionHelper::flash(), AuthComponent::initialize(), AuthComponent::mapActions(), DboMssql::read(), SessionHelper::read(), valid(), and SchemaShell::view().

readable (  ) 

Returns true if the File is readable.

Returns:
boolean true if file is readable, false otherwise public

Definition at line 447 of file file.php.

safe ( name = null,
ext = null 
)

makes filename safe for saving

Parameters:
string $name the name of the file to make safe if different from $this->name
Returns:
string $ext the extension of the file public

Definition at line 350 of file file.php.

References ext(), and name().

Referenced by JavascriptHelper::__construct(), __construct(), and JavascriptHelper::codeBlock().

size (  ) 

Returns the Filesize

Returns:
integer size of the file in bytes, or false in case of an error public

Definition at line 417 of file file.php.

References exists().

Referenced by FormHelper::file(), and md5().

writable (  ) 

Returns true if the File is writable.

Returns:
boolean true if its writable, false otherwise public

Definition at line 429 of file file.php.

Referenced by FileEngine::__active(), Configure::__writeConfig(), Folder::copy(), and CakeLog::write().

write ( data,
mode = 'w',
force = false 
)

Write given data to this File.

Parameters:
string $data Data to write to this File.
string $mode Mode of writing. See fwrite().
string $force force the file to open
Returns:
boolean Success public

Definition at line 242 of file file.php.

References open().

Referenced by __initSession(), _checkValid(), append(), ProjectTask::cakeAdmin(), ProjectTask::corePath(), SchemaShell::dump(), Shell::getAdmin(), and ProjectTask::securitySalt().


Variable Documentation

$handle = null

Definition at line 69 of file file.php.

Referenced by EmailComponent::__attachFiles(), Folder::copy(), and MediaView::render().

$lock = null

Definition at line 76 of file file.php.

$path = null

Definition at line 85 of file file.php.

Referenced by ShellDispatcher::__buildPaths(), __construct(), App::__find(), EmailComponent::__findFiles(), TestSuiteShell::__findFolderByCategory(), Configure::__list(), Configure::__loadBootstrap(), ApiShell::__parseClass(), App::__paths(), TestSuiteShell::__run(), App::__settings(), CacheHelper::__writeFile(), View::_getLayoutFileName(), ScaffoldView::_getViewFileName(), View::_getViewFileName(), ProjectTask::bake(), Configure::buildPaths(), cache(), Dispatcher::cached(), Set::check(), Set::classicExtract(), ProjectTask::corePath(), Configure::corePaths(), FormHelper::create(), Shell::createFile(), ProjectTask::createHome(), HtmlHelper::css(), ShellDispatcher::dispatch(), PagesController::display(), View::element(), ProjectTask::execute(), Set::extract(), fileExistsInPath(), ModelTask::fixture(), Set::flatten(), ShellDispatcher::help(), Set::insert(), Configure::listObjects(), Configure::load(), Shell::loadTasks(), BakeShell::loadTasks(), ApiShell::main(), make_clean_css(), AclNode::node(), TreeBehavior::recover(), Set::remove(), MediaView::render(), ProjectTask::securitySalt(), Set::sort(), SchemaShell::startup(), Debugger::trimPath(), Helper::webroot(), and write_css_cache().


Generated on Sun Nov 22 00:30:54 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7