Mage_Install_Model_Installer_Filesystem Class Reference

Inheritance diagram for Mage_Install_Model_Installer_Filesystem:

Mage_Install_Model_Installer_Abstract

List of all members.

Public Member Functions

 __construct ()
 install ()

Public Attributes

const MODE_WRITE = 'write'
const MODE_READ = 'read'

Protected Member Functions

 _checkFilesystem ()
 _checkPath ($path, $recursive, $existence, $mode)


Detailed Description

Definition at line 34 of file Filesystem.php.


Constructor & Destructor Documentation

__construct (  ) 

Definition at line 39 of file Filesystem.php.

00040     {
00041     }


Member Function Documentation

_checkFilesystem (  )  [protected]

Check file system by config

Returns:
bool

Definition at line 60 of file Filesystem.php.

00061     {
00062         $res = true;
00063         $config = Mage::getSingleton('install/config')->getPathForCheck();
00064 
00065         if (isset($config['writeable'])) {
00066             foreach ($config['writeable'] as $item) {
00067                 $recursive = isset($item['recursive']) ? $item['recursive'] : false;
00068                 $existence = isset($item['existence']) ? $item['existence'] : false;
00069                 $checkRes = $this->_checkPath($item['path'], $recursive, $existence, 'write');
00070                 $res = $res && $checkRes;
00071             }
00072         }
00073         return $res;
00074     }

_checkPath ( path,
recursive,
existence,
mode 
) [protected]

Check file system path

Parameters:
string $path
bool $recursive
bool $existence
string $mode
Returns:
bool

Definition at line 85 of file Filesystem.php.

00086     {
00087         $res = true;
00088         $fullPath = dirname(Mage::getRoot()).$path;
00089         if ($mode == self::MODE_WRITE) {
00090             $setError = false;
00091             if ($existence) {
00092                 if ((is_dir($fullPath) && !is_dir_writeable($fullPath)) || !is_writable($fullPath)) {
00093                     $setError = true;
00094                 }
00095             }
00096             else {
00097                 if (file_exists($fullPath) && !is_writable($fullPath)) {
00098                     $setError = true;
00099                 }
00100             }
00101 
00102             if ($setError) {
00103                 $this->_getInstaller()->getDataModel()->addError(
00104                     Mage::helper('install')->__('Path "%s" must be writable', $fullPath)
00105                 );
00106                 $res = false;
00107             }
00108         }
00109 
00110         if ($recursive && is_dir($fullPath)) {
00111             foreach (new DirectoryIterator($fullPath) as $file) {
00112                 if (!$file->isDot() && $file->getFilename() != '.svn' && $file->getFilename() != '.htaccess') {
00113                     $res = $res && $this->_checkPath($path.DS.$file->getFilename(), $recursive, $existence, $mode);
00114                 }
00115             }
00116         }
00117         return $res;
00118     }

install (  ) 

Check and prepare file system

Definition at line 47 of file Filesystem.php.

00048     {
00049         if (!$this->_checkFilesystem()) {
00050             throw new Exception();
00051         };
00052         return $this;
00053     }


Member Data Documentation

const MODE_READ = 'read'

Definition at line 37 of file Filesystem.php.

const MODE_WRITE = 'write'

Definition at line 36 of file Filesystem.php.


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

Generated on Sat Jul 4 17:24:27 2009 for Magento by  doxygen 1.5.8