ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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. More...
 
 getContainerId ()
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 writeToFile ($a_data, $a_absolute_path)
 Write data to file. More...
 
 deleteFile ($a_abs_name)
 Delete file. More...
 
 deleteDirectory ($a_abs_name)
 Delete directory. More...
 
 delete ()
 Delete complete directory. More...
 
 copyFile ($a_from, $a_to)
 Copy files. More...
 
 appendToPath ($a_appendix)
 
 getStorageType ()
 
 getPath ()
 Get path. More...
 
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 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. More...
 
static _copyDirectory ($a_source, $a_target)
 Copy directory and all contents. More...
 
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 

Data Fields

const STORAGE_WEB = 1
 
const STORAGE_DATA = 2
 
const STORAGE_SECURED = 3
 
const FACTOR = 100
 
const MAX_EXPONENT = 3
 
const SECURED_DIRECTORY = "sec"
 

Protected Member Functions

 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 
 init ()
 Read path info. More...
 
 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 

Protected Attributes

 $path
 

Private Member Functions

 init ()
 Read path info. More...
 

Private Attributes

 $container_id
 
 $storage_type
 
 $path_conversion = false
 
 $short_path
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct() [1/2]

ilFileSystemStorage::__construct (   $a_storage_type,
  $a_path_conversion,
  $a_container_id 
)

Constructor.

@access public

Parameters
intstorage type
boolEn/Disable automatic path conversion. If enabled files with id 123 will be stored in directory files/1/file_123
intobject id of container (e.g file_id or mob_id)

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

60 {
61 $this->storage_type = $a_storage_type;
62 $this->path_conversion = $a_path_conversion;
63 $this->container_id = $a_container_id;
64
65 // Get path info
66 $this->init();
67 }

References init().

+ Here is the call graph for this function:

◆ __construct() [2/2]

ilFileSystemStorage::__construct (   $a_storage_type,
  $a_path_conversion,
  $a_container_id 
)

Constructor.

@access public

Parameters
intstorage type
boolEn/Disable automatic path conversion. If enabled files with id 123 will be stored in directory files/1/file_123
intobject id of container (e.g file_id or mob_id)

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

51 {
52 $this->storage_type = $a_storage_type;
53 $this->path_conversion = $a_path_conversion;
54 $this->container_id = $a_container_id;
55
56 // Get path info
57 $this->init();
58 }

References init().

+ Here is the call graph for this function:

Member Function Documentation

◆ _copyDirectory()

static ilFileSystemStorage::_copyDirectory (   $a_source,
  $a_target 
)
static

Copy directory and all contents.

Parameters
string$a_sourceabsolute source path
string$a_targetabsolute target path

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

278 {
279 return ilUtil::rCopy($a_source, $a_target);
280 }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.

References ilUtil\rCopy().

Referenced by ilFSStorageCourse\_clone(), and ilObjPortfolioBase\cloneBasics().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _createPathFromId() [1/2]

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.

@access public

Parameters
intcontainer id
stringname

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

84 {
85 $path = array();
86 $found = false;
87 $num = $a_container_id;
88 for ($i = self::MAX_EXPONENT; $i > 0;$i--) {
89 $factor = pow(self::FACTOR, $i);
90 if (($tmp = (int) ($num / $factor)) or $found) {
91 $path[] = $tmp;
92 $num = $num % $factor;
93 $found = true;
94 }
95 }
96
97 if (count($path)) {
98 $path_string = (implode('/', $path) . '/');
99 }
100 return $path_string . $a_name . '_' . $a_container_id;
101 }
$i
Definition: metadata.php:24

References $i, and $path.

Referenced by ilExport\_getExportDirectory(), and init().

+ Here is the caller graph for this function:

◆ _createPathFromId() [2/2]

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.

@access public

Parameters
intcontainer id
stringname

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

70 {
71 $path = array();
72 $found = false;
73 $num = $a_container_id;
74 for ($i = self::MAX_EXPONENT; $i > 0;$i--) {
75 $factor = pow(self::FACTOR, $i);
76 if (($tmp = (int) ($num / $factor)) or $found) {
77 $path[] = $tmp;
78 $num = $num % $factor;
79 $found = true;
80 }
81 }
82
83 if (count($path)) {
84 $path_string = (implode('/', $path));
85 }
86 return $path_string;
87 }

References $i, and $path.

◆ appendToPath()

ilFileSystemStorage::appendToPath (   $a_appendix)

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

283 {
284 $this->path .= $a_appendix;
285 }

Referenced by ilFSStorageMail\__construct().

+ Here is the caller graph for this function:

◆ copyFile()

ilFileSystemStorage::copyFile (   $a_from,
  $a_to 
)

Copy files.

@access public

Parameters
stringabsolute source
stringabsolute target

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

263 {
264 if (@file_exists($a_from)) {
265 @copy($a_from, $a_to);
266 return true;
267 }
268 return false;
269 }

◆ create() [1/2]

ilFileSystemStorage::create ( )

Create directory.

@access public

Reimplemented in ilFSStorageExercise, ilFSWebStorageExercise, ilIndividualAssessmentFileStorage, ilTestProcessLockFileStorage, and ilAssQuestionProcessLockFileStorage.

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

133 {
134 if (!file_exists($this->path)) {
135 ilUtil::makeDirParents($this->path);
136 }
137 return true;
138 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\makeDirParents().

Referenced by ilLearningSequenceFilesystem\__construct(), and ilRestFileStorage\init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create() [2/2]

ilFileSystemStorage::create ( )

Create directory.

@access public

Reimplemented in ilFSStorageExercise, ilFSWebStorageExercise, ilIndividualAssessmentFileStorage, ilTestProcessLockFileStorage, and ilAssQuestionProcessLockFileStorage.

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

119 {
120 if (!file_exists($this->short_path)) {
122 }
123 return true;
124 }
removeTrailingPathSeparators($path)
makeDirParents($a_dir)
Create a new directory and all parent directories.

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

+ Here is the call graph for this function:

◆ delete()

ilFileSystemStorage::delete ( )

Delete complete directory.

@access public

Parameters

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

249 {
250 return ilUtil::delDir($this->getAbsolutePath());
251 }
getAbsolutePath()
Get absolute path of storage directory.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

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

+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileSystemStorage::deleteDirectory (   $a_abs_name)

Delete directory.

@access public

Parameters
stringabsolute name

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

232 {
233 if (@file_exists($a_abs_name)) {
234 ilUtil::delDir($a_abs_name);
235 return true;
236 }
237 return false;
238 }

References ilUtil\delDir().

Referenced by ilFSStorageCourse\deleteArchive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteFile()

ilFileSystemStorage::deleteFile (   $a_abs_name)

Delete file.

@access public

Parameters
stringabsolute name

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

216 {
217 if (@file_exists($a_abs_name)) {
218 @unlink($a_abs_name);
219 return true;
220 }
221 return false;
222 }

Referenced by ilFSStorageCourse\deleteArchive(), ilIndividualAssessmentFileStorage\deleteCurrentFile(), ilIndividualAssessmentFileStorage\deleteFileByName(), ilFSStorageCourse\deleteMemberExportFile(), and ilFSStorageGroup\deleteMemberExportFile().

+ Here is the caller graph for this function:

◆ getAbsolutePath() [1/2]

◆ getAbsolutePath() [2/2]

ilFileSystemStorage::getAbsolutePath ( )

Get absolute path of storage directory.

@access public

Reimplemented in ilIndividualAssessmentFileStorage.

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

134 {
135 return $this->path;
136 }

References $path.

◆ getContainerId()

ilFileSystemStorage::getContainerId ( )

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

References $container_id.

Referenced by ilFSStorageCourse\getMemberExportFiles(), and ilFSStorageGroup\getMemberExportFiles().

+ Here is the caller graph for this function:

◆ getPath()

ilFileSystemStorage::getPath ( )

◆ getPathPostfix() [1/2]

ilFileSystemStorage::getPathPostfix ( )
abstractprotected

◆ getPathPostfix() [2/2]

◆ getPathPrefix() [1/2]

ilFileSystemStorage::getPathPrefix ( )
abstractprotected

◆ getPathPrefix() [2/2]

◆ getShortPath()

ilFileSystemStorage::getShortPath ( )

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

References $short_path.

◆ getStorageType()

ilFileSystemStorage::getStorageType ( )

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

References $storage_type.

Referenced by ilFSStorageMail\getRelativePathExMailDirectory().

+ Here is the caller graph for this function:

◆ init() [1/2]

ilFileSystemStorage::init ( )
protected

Read path info.

@access private

Reimplemented in ilFSStorageExercise, ilFSWebStorageExercise, and ilRestFileStorage.

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

158 {
159 switch ($this->storage_type) {
161 $this->path = ilUtil::getDataDir();
162 break;
163
165 $this->path = ilUtil::getWebspaceDir();
166 break;
167
169 $this->path = ilUtil::getWebspaceDir();
170 $this->path = ilUtil::removeTrailingPathSeparators($this->path);
171 $this->path .= '/' . self::SECURED_DIRECTORY;
172 break;
173 }
174 $this->path = ilUtil::removeTrailingPathSeparators($this->path);
175 $this->path .= '/';
176
177 // Append path prefix
178 $this->path .= ($this->getPathPrefix() . '/');
179
180 if ($this->path_conversion) {
181 $this->path .= self::_createPathFromId($this->container_id, $this->getPathPostfix());
182 } else {
183 $this->path .= ($this->getPathPostfix() . '_' . $this->container_id);
184 }
185 return true;
186 }
getPathPrefix()
Get path prefix.
static _createPathFromId($a_container_id, $a_name)
Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.
getPathPostfix()
Get directory name.
static getDataDir()
get data directory (outside webspace)
static getWebspaceDir($mode="filesystem")
get webspace directory
static removeTrailingPathSeparators($path)

References $container_id, _createPathFromId(), ilUtil\getDataDir(), getPathPostfix(), getPathPrefix(), ilUtil\getWebspaceDir(), ilUtil\removeTrailingPathSeparators(), SECURED_DIRECTORY, STORAGE_DATA, STORAGE_SECURED, and STORAGE_WEB.

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init() [2/2]

ilFileSystemStorage::init ( )
private

Read path info.

@access private

Reimplemented in ilFSStorageExercise, ilFSWebStorageExercise, and ilRestFileStorage.

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

154 {
155 switch ($this->storage_type) {
157 $this->path = ilUpdateUtils::getDataDir();
158 break;
159
161 $this->path = ilUpdateUtils::getWebspaceDir();
162 break;
163 }
164 $this->path = ilUpdateUtils::removeTrailingPathSeparators($this->path);
165 $this->path .= '/';
166
167 // Append path prefix
168 $this->path .= ($this->getPathPrefix() . '/');
169
170 if ($this->path_conversion) {
171 if ($path_id = self::_createPathFromId($this->container_id, $this->getPathPostfix())) {
172 $this->path = $this->path . '/' . $path_id;
173 $this->path .= '/';
174 $this->short_path = $this->path;
175 } else {
176 $this->short_path = $this->path;
177 }
178 $this->path .= ($this->getPathPostfix() . '_' . $this->container_id);
179 } else {
180 $this->short_path = $this->path;
181 $this->path .= ($this->getPathPostfix() . '_' . $this->container_id);
182 }
183 return true;
184 }
getWebspaceDir($mode="filesystem")
get webspace directory
getDataDir()
get data directory (outside webspace)

References $container_id, $path, ilUpdateUtils\getDataDir(), getPathPostfix(), getPathPrefix(), ilUpdateUtils\getWebspaceDir(), ilUpdateUtils\removeTrailingPathSeparators(), STORAGE_DATA, and STORAGE_WEB.

+ Here is the call graph for this function:

◆ rename()

ilFileSystemStorage::rename (   $from,
  $to 
)

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

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

References rename().

Referenced by rename(), and ilFSStorageExercise\uploadFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeToFile()

ilFileSystemStorage::writeToFile (   $a_data,
  $a_absolute_path 
)

Write data to file.

@access public

Parameters

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

196 {
197 if (!$fp = @fopen($a_absolute_path, 'w+')) {
198 return false;
199 }
200 if (@fwrite($fp, $a_data) === false) {
201 @fclose($fp);
202 return false;
203 }
204 @fclose($fp);
205 return true;
206 }

Referenced by ilFSStorageCourse\addMemberExportFile(), ilFSStorageGroup\addMemberExportFile(), ilRestFileStorage\createFile(), ilRestFileStorage\storeFileForRest(), and ilFSStorageCourse\writeArchiveFile().

+ Here is the caller graph for this function:

Field Documentation

◆ $container_id

ilFileSystemStorage::$container_id
private

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

Referenced by getContainerId(), and init().

◆ $path

◆ $path_conversion

ilFileSystemStorage::$path_conversion = false
private

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

◆ $short_path

ilFileSystemStorage::$short_path
private

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

Referenced by getShortPath().

◆ $storage_type

ilFileSystemStorage::$storage_type
private

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

Referenced by getStorageType().

◆ FACTOR

const ilFileSystemStorage::FACTOR = 100

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

◆ MAX_EXPONENT

const ilFileSystemStorage::MAX_EXPONENT = 3

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

◆ SECURED_DIRECTORY

const ilFileSystemStorage::SECURED_DIRECTORY = "sec"

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

Referenced by init().

◆ STORAGE_DATA

◆ STORAGE_SECURED

const ilFileSystemStorage::STORAGE_SECURED = 3

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

Referenced by init().

◆ STORAGE_WEB

const ilFileSystemStorage::STORAGE_WEB = 1

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