Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Private Member Functions | Private Attributes

ilFileSystemStorage Class Reference

Inheritance diagram for ilFileSystemStorage:
Collaboration diagram for ilFileSystemStorage:

Public Member Functions

 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor.
 getContainerId ()
 create ()
 Create directory.
 getAbsolutePath ()
 Get absolute path of storage directory.
 writeToFile ($a_data, $a_absolute_path)
 Write data to file.
 deleteFile ($a_abs_name)
 Delete file.
 deleteDirectory ($a_abs_name)
 Delete directory.
 delete ()
 Delete complete directory.
 copyFile ($a_from, $a_to)
 Copy files.
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor.
 create ()
 Create directory.
 getAbsolutePath ()
 Get absolute path of storage directory.
 getShortPath ()
 rename ($from, $to)

Static Public Member Functions

static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.
 _copyDirectory ($a_source, $a_target)
 Copy directory and all contents.
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.

Data Fields

const STORAGE_WEB = 1
const STORAGE_DATA = 2
const FACTOR = 100
const MAX_EXPONENT = 3

Protected Member Functions

 getPathPrefix ()
 Get path prefix.
 getPathPostfix ()
 Get directory name.
 getPathPrefix ()
 Get path prefix.
 getPathPostfix ()
 Get directory name.

Private Member Functions

 init ()
 Read path info.
 init ()
 Read path info.

Private Attributes

 $container_id
 $storage_type
 $path_conversion = false
 $path
 $short_path

Detailed Description

Definition at line 34 of file class.ilFileSystemStorage.php.


Constructor & Destructor Documentation

ilFileSystemStorage::__construct ( a_storage_type,
a_path_conversion,
a_container_id 
)

Constructor.

public

Parameters:
int storage type
bool En/Disable automatic path conversion. If enabled files with id 123 will be stored in directory files/1/file_123
int object id of container (e.g file_id or mob_id)

Definition at line 58 of file class.ilFileSystemStorage.php.

References init().

        {
                $this->storage_type = $a_storage_type;
                $this->path_conversion = $a_path_conversion;
                $this->container_id = $a_container_id;
                
                // Get path info
                $this->init();
        }

Here is the call graph for this function:

ilFileSystemStorage::__construct ( a_storage_type,
a_path_conversion,
a_container_id 
)

Constructor.

public

Parameters:
int storage type
bool En/Disable automatic path conversion. If enabled files with id 123 will be stored in directory files/1/file_123
int object id of container (e.g file_id or mob_id)

Definition at line 50 of file class.ilFileSystemStorage.php.

References init().

        {
                $this->storage_type = $a_storage_type;
                $this->path_conversion = $a_path_conversion;
                $this->container_id = $a_container_id;
                
                // Get path info
                $this->init();
        }

Here is the call graph for this function:


Member Function Documentation

ilFileSystemStorage::_copyDirectory ( a_source,
a_target 
) [static]

Copy directory and all contents.

public

Parameters:
string absolute source path
string absolute target path

Definition at line 286 of file class.ilFileSystemStorage.php.

References ilUtil::rCopy().

Referenced by ilFSStorageCourse::_clone().

        {
                return ilUtil::rCopy($a_source,$a_target);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

static ilFileSystemStorage::_createPathFromId ( a_container_id,
a_name 
) [static]

Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.

public

Parameters:
int container id
string name

Definition at line 82 of file class.ilFileSystemStorage.php.

References $path.

Referenced by ilLuceneIndexer::__indexFiles(), and init().

        {
                $path = array();
                $found = false;
                $num = $a_container_id;
                for($i = self::MAX_EXPONENT; $i > 0;$i--)
                {
                        $factor = pow(self::FACTOR,$i);
                        if(($tmp = (int) ($num / $factor)) or $found)
                        {
                                $path[] = $tmp;
                                $num = $num % $factor;
                                $found = true;
                        }       
                }

                if(count($path))
                {
                        $path_string = (implode('/',$path).'/');
                }
                return $path_string.$a_name.'_'.$a_container_id;
        }

Here is the caller graph for this function:

static ilFileSystemStorage::_createPathFromId ( a_container_id,
a_name 
) [static]

Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.

public

Parameters:
int container id
string name

Definition at line 69 of file class.ilFileSystemStorage.php.

References $path.

        {
                $path = array();
                $found = false;
                $num = $a_container_id;
                for($i = self::MAX_EXPONENT; $i > 0;$i--)
                {
                        $factor = pow(self::FACTOR,$i);
                        if(($tmp = (int) ($num / $factor)) or $found)
                        {
                                $path[] = $tmp;
                                $num = $num % $factor;
                                $found = true;
                        }       
                }

                if(count($path))
                {
                        $path_string = (implode('/',$path));
                }
                return $path_string;
        }

ilFileSystemStorage::copyFile ( a_from,
a_to 
)

Copy files.

public

Parameters:
string absolute source
string absolute target

Definition at line 267 of file class.ilFileSystemStorage.php.

        {
                if(@file_exists($a_from))
                {
                        @copy($a_from,$a_to);
                        return true;
                }
                return false;
        }

ilFileSystemStorage::create (  ) 

Create directory.

public

Definition at line 134 of file class.ilFileSystemStorage.php.

References ilUtil::makeDirParents().

        {
                if(!file_exists($this->path))
                {
                        ilUtil::makeDirParents($this->path);
                }
                return true;
        }

Here is the call graph for this function:

ilFileSystemStorage::create (  ) 

Create directory.

public

Definition at line 121 of file class.ilFileSystemStorage.php.

References ilUpdateUtils::makeDirParents(), and ilUpdateUtils::removeTrailingPathSeparators().

        {
                if(!file_exists($this->short_path))
                {
                        ilUpdateUtils::makeDirParents(ilUpdateUtils::removeTrailingPathSeparators($this->short_path));
                }
                return true;
        }

Here is the call graph for this function:

ilFileSystemStorage::delete (  ) 

Delete complete directory.

public

Parameters:
 

Definition at line 253 of file class.ilFileSystemStorage.php.

References ilUtil::delDir(), and getAbsolutePath().

        {
                return ilUtil::delDir($this->getAbsolutePath());
        }

Here is the call graph for this function:

ilFileSystemStorage::deleteDirectory ( a_abs_name  ) 

Delete directory.

public

Parameters:
string absolute name

Definition at line 235 of file class.ilFileSystemStorage.php.

References ilUtil::delDir().

Referenced by ilFSStorageCourse::deleteArchive().

        {
                if(@file_exists($a_abs_name))
                {
                        ilUtil::delDir($a_abs_name);
                        return true;
                }
                return false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilFileSystemStorage::deleteFile ( a_abs_name  ) 

Delete file.

public

Parameters:
string absolute name

Definition at line 218 of file class.ilFileSystemStorage.php.

Referenced by ilFSStorageCourse::deleteArchive(), and ilFSStorageCourse::deleteMemberExportFile().

        {
                if(@file_exists($a_abs_name))
                {
                        @unlink($a_abs_name);
                        return true;
                }
                return false;
        }

Here is the caller graph for this function:

ilFileSystemStorage::getAbsolutePath (  ) 

Get absolute path of storage directory.

public

Definition at line 137 of file class.ilFileSystemStorage.php.

        {
                return $this->path;
        }

ilFileSystemStorage::getAbsolutePath (  ) 

Get absolute path of storage directory.

public

Definition at line 150 of file class.ilFileSystemStorage.php.

Referenced by ilFSStorageEvent::createDirectory(), delete(), ilFSStorageCourse::getArchiveDirectory(), ilFSStorageCourse::getInfoDirectory(), and ilFSStorageCourse::getMemberExportDirectory().

        {
                return $this->path;
        }

Here is the caller graph for this function:

ilFileSystemStorage::getContainerId (  ) 

Definition at line 68 of file class.ilFileSystemStorage.php.

Referenced by ilFSStorageCourse::getMemberExportFiles().

        {
                return $this->container_id;
        }

Here is the caller graph for this function:

ilFileSystemStorage::getPathPostfix (  )  [abstract, protected]

Get directory name.

E.g for files => file Only relative path, no trailing slash '_<obj_id>' will be appended automatically

protected

Returns:
string directory name

Reimplemented in ilFSStorageCourse, ilFSStorageEvent, ilFSStorageFile, ilFSStorageCourse, ilFSStorageEvent, and ilFSStorageFile.

Referenced by init().

Here is the caller graph for this function:

ilFileSystemStorage::getPathPostfix (  )  [abstract, protected]

Get directory name.

E.g for files => file Only relative path, no trailing slash '_<obj_id>' will be appended automatically

protected

Returns:
string directory name

Reimplemented in ilFSStorageCourse, ilFSStorageEvent, ilFSStorageFile, ilFSStorageCourse, ilFSStorageEvent, and ilFSStorageFile.

ilFileSystemStorage::getPathPrefix (  )  [abstract, protected]

Get path prefix.

Prefix that will be prepended to the path No trailing slash. E.g ilFiles for files

protected

Returns:
string path prefix e.g files

Reimplemented in ilFSStorageCourse, ilFSStorageEvent, ilFSStorageFile, ilFSStorageCourse, ilFSStorageEvent, and ilFSStorageFile.

Referenced by init().

Here is the caller graph for this function:

ilFileSystemStorage::getPathPrefix (  )  [abstract, protected]

Get path prefix.

Prefix that will be prepended to the path No trailing slash. E.g ilFiles for files

protected

Returns:
string path prefix e.g files

Reimplemented in ilFSStorageCourse, ilFSStorageEvent, ilFSStorageFile, ilFSStorageCourse, ilFSStorageEvent, and ilFSStorageFile.

ilFileSystemStorage::getShortPath (  ) 

Definition at line 142 of file class.ilFileSystemStorage.php.

        {
                return $this->short_path;
        }

ilFileSystemStorage::init (  )  [private]

Read path info.

private

Definition at line 157 of file class.ilFileSystemStorage.php.

References ilUpdateUtils::getDataDir(), getPathPostfix(), getPathPrefix(), ilUpdateUtils::getWebspaceDir(), and ilUpdateUtils::removeTrailingPathSeparators().

        {
                switch($this->storage_type)
                {
                        case self::STORAGE_DATA:
                                $this->path = ilUpdateUtils::getDataDir();
                                break;
                                
                        case self::STORAGE_WEB:
                                $this->path = ilUpdateUtils::getWebspaceDir();
                                break;
                }
                $this->path = ilUpdateUtils::removeTrailingPathSeparators($this->path);
                $this->path .= '/';
                
                // Append path prefix
                $this->path .= ($this->getPathPrefix().'/');
                
                if($this->path_conversion)
                {
                        if($path_id = self::_createPathFromId($this->container_id,$this->getPathPostfix()))
                        {
                                $this->path = $this->path.'/'.$path_id;
                                $this->path .= '/';
                                $this->short_path = $this->path;
                        }
                        else
                        {
                                $this->short_path = $this->path;
                        }
                        $this->path .= ($this->getPathPostfix().'_'.$this->container_id);
                }
                else
                {
                        $this->short_path = $this->path;
                        $this->path .= ($this->getPathPostfix().'_'.$this->container_id);
                }
                return true;
        }

Here is the call graph for this function:

ilFileSystemStorage::init (  )  [private]

Read path info.

private

Definition at line 160 of file class.ilFileSystemStorage.php.

References _createPathFromId(), ilUtil::getDataDir(), getPathPostfix(), getPathPrefix(), ilUtil::getWebspaceDir(), and ilUtil::removeTrailingPathSeparators().

Referenced by __construct().

        {
                switch($this->storage_type)
                {
                        case self::STORAGE_DATA:
                                $this->path = ilUtil::getDataDir();
                                break;
                                
                        case self::STORAGE_WEB:
                                $this->path = ilUtil::getWebspaceDir();
                                break;
                }
                $this->path = ilUtil::removeTrailingPathSeparators($this->path);
                $this->path .= '/';
                
                // Append path prefix
                $this->path .= ($this->getPathPrefix().'/');
                
                if($this->path_conversion)
                {
                        $this->path .= self::_createPathFromId($this->container_id,$this->getPathPostfix());
                }
                else
                {
                        $this->path .= ($this->getPathPostfix().'_'.$this->container_id);
                }
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilFileSystemStorage::rename ( from,
to 
)

Definition at line 147 of file class.ilFileSystemStorage.php.

        {
                return @rename($from,$to);
        }

ilFileSystemStorage::writeToFile ( a_data,
a_absolute_path 
)

Write data to file.

public

Parameters:
 

Definition at line 196 of file class.ilFileSystemStorage.php.

Referenced by ilFSStorageCourse::addMemberExportFile(), and ilFSStorageCourse::writeArchiveFile().

        {
                if(!$fp = @fopen($a_absolute_path,'w+'))
                {
                        return false;
                }
                if(@fwrite($fp,$a_data) === false)
                {
                        @fclose($fp);
                        return false;
                }
                @fclose($fp);
                return true;            
        }

Here is the caller graph for this function:


Field Documentation

ilFileSystemStorage::$container_id [private]

Definition at line 43 of file class.ilFileSystemStorage.php.

ilFileSystemStorage::$path [private]

Definition at line 47 of file class.ilFileSystemStorage.php.

Referenced by _createPathFromId().

ilFileSystemStorage::$path_conversion = false [private]

Definition at line 45 of file class.ilFileSystemStorage.php.

ilFileSystemStorage::$short_path [private]

Definition at line 39 of file class.ilFileSystemStorage.php.

ilFileSystemStorage::$storage_type [private]

Definition at line 44 of file class.ilFileSystemStorage.php.

Definition at line 39 of file class.ilFileSystemStorage.php.

Definition at line 40 of file class.ilFileSystemStorage.php.

Definition at line 36 of file class.ilFileSystemStorage.php.


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