ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilUpdateUtils Class Reference

util class various functions, usage as namespace More...

+ Collaboration diagram for ilUpdateUtils:

Public Member Functions

 removeTrailingPathSeparators ($path)
 
 getWebspaceDir ($mode="filesystem")
 get webspace directory More...
 
 getDataDir ()
 get data directory (outside webspace) More...
 
 makeDir ($a_dir)
 creates a new directory and inherits all filesystem permissions of the parent directory You may pass only the name of your new directory or with the entire path or relative path information. More...
 
 makeDirParents ($a_dir)
 Create a new directory and all parent directories. More...
 
 delDir ($a_dir)
 removes a dir and all its content (subdirs and files) recursively More...
 
 getDir ($a_dir)
 get directory More...
 

Detailed Description

util class various functions, usage as namespace

Author
Sascha Hofmann sasch.nosp@m.ahof.nosp@m.mann@.nosp@m.gmx..nosp@m.de
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id
class.ilUtil.php 13126 2007-01-29 15:51:03 +0000 (Mo, 29 Jan 2007) smeyer

Definition at line 37 of file class.ilUpdateUtils.php.

Member Function Documentation

◆ delDir()

ilUpdateUtils::delDir (   $a_dir)

removes a dir and all its content (subdirs and files) recursively

public

Parameters
stringdir to delete
Author
Unknown flexe.nosp@m.r@cu.nosp@m.tephp.nosp@m..com (source: http://www.php.net/rmdir)

Definition at line 206 of file class.ilUpdateUtils.php.

References $file, $files, array, ilUtil\delDir(), and file.

207  {
208  if (!is_dir($a_dir) || is_int(strpos($a_dir, "..")))
209  {
210  return;
211  }
212 
213  $current_dir = opendir($a_dir);
214 
215  $files = array();
216 
217  // this extra loop has been necessary because of a strange bug
218  // at least on MacOS X. A looped readdir() didn't work
219  // correctly with larger directories
220  // when an unlink happened inside the loop. Getting all files
221  // into the memory first solved the problem.
222  while($entryname = readdir($current_dir))
223  {
224  $files[] = $entryname;
225  }
226 
227  foreach($files as $file)
228  {
229  if(is_dir($a_dir."/".$file) and ($file != "." and $file!=".."))
230  {
231  ilUtil::delDir(${a_dir}."/".${file});
232  }
233  elseif ($file != "." and $file != "..")
234  {
235  unlink(${a_dir}."/".${file});
236  }
237  }
238 
239  closedir($current_dir);
240  rmdir(${a_dir});
241  }
$files
Definition: add-vimline.php:18
Reload workbook from saved file
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ getDataDir()

ilUpdateUtils::getDataDir ( )

get data directory (outside webspace)

Definition at line 81 of file class.ilUpdateUtils.php.

Referenced by ilFileSystemStorage\init().

82  {
83  return CLIENT_DATA_DIR;
84  //global $ilias;
85 
86  //return $ilias->ini->readVariable("server", "data_dir");
87  }
+ Here is the caller graph for this function:

◆ getDir()

ilUpdateUtils::getDir (   $a_dir)

get directory

Definition at line 247 of file class.ilUpdateUtils.php.

References $files, $size, and array.

248  {
249  $current_dir = opendir($a_dir);
250 
251  $dirs = array();
252  $files = array();
253  while($entry = readdir($current_dir))
254  {
255  if(is_dir($a_dir."/".$entry))
256  {
257  $dirs[$entry] = array("type" => "dir", "entry" => $entry);
258  }
259  else
260  {
261  $size = filesize($a_dir."/".$entry);
262  $files[$entry] = array("type" => "file", "entry" => $entry,
263  "size" => $size);
264  }
265  }
266  ksort($dirs);
267  ksort($files);
268 
269  return array_merge($dirs, $files);
270  }
$files
Definition: add-vimline.php:18
$size
Definition: RandomTest.php:79
Create styles array
The data for the language used.

◆ getWebspaceDir()

ilUpdateUtils::getWebspaceDir (   $mode = "filesystem")

get webspace directory

Parameters
string$modeuse "filesystem" for filesystem operations and "output" for output operations, e.g. images

Definition at line 55 of file class.ilUpdateUtils.php.

References defined.

Referenced by ilFileSystemStorage\init().

56  {
57  global $ilias;
58 
59  if ($mode == "filesystem")
60  {
61  return "./".ILIAS_WEB_DIR."/".$ilias->client_id;
62  }
63  else
64  {
65  if (defined("ILIAS_MODULE"))
66  {
67  return "../".ILIAS_WEB_DIR."/".$ilias->client_id;
68  }
69  else
70  {
71  return "./".ILIAS_WEB_DIR."/".$ilias->client_id;
72  }
73  }
74 
75  //return $ilias->ini->readVariable("server","webspace_dir");
76  }
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
+ Here is the caller graph for this function:

◆ makeDir()

ilUpdateUtils::makeDir (   $a_dir)

creates a new directory and inherits all filesystem permissions of the parent directory You may pass only the name of your new directory or with the entire path or relative path information.

examples: a_dir = /tmp/test/your_dir a_dir = ../test/your_dir a_dir = your_dir (–> creates your_dir in current directory)

public

Parameters
string[path] + directory name
Returns
boolean

Definition at line 103 of file class.ilUpdateUtils.php.

References $path.

104  {
105  $a_dir = trim($a_dir);
106 
107  // remove trailing slash (bugfix for php 4.2.x)
108  if (substr($a_dir,-1) == "/")
109  {
110  $a_dir = substr($a_dir,0,-1);
111  }
112 
113  // check if a_dir comes with a path
114  if (!($path = substr($a_dir,0, strrpos($a_dir,"/") - strlen($a_dir))))
115  {
116  $path = ".";
117  }
118 
119  // create directory with file permissions of parent directory
120  umask(0000);
121  return @mkdir($a_dir,fileperms($path));
122  }
$path
Definition: aliased.php:25

◆ makeDirParents()

ilUpdateUtils::makeDirParents (   $a_dir)

Create a new directory and all parent directories.

Creates a new directory and inherits all filesystem permissions of the parent directory If the parent directories doesn't exist, they will be created recursively. The directory name NEEDS TO BE an absolute path, because it seems that relative paths are not working with PHP's file_exists function.

Author
Helmut Schottmüller hscho.nosp@m.ttm@.nosp@m.tzi.d.nosp@m.e
Parameters
string$a_dirThe directory name to be created public

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

References array, and Monolog\Handler\error_log().

Referenced by ilFileSystemStorage\create().

138  {
139  $dirs = array($a_dir);
140  $a_dir = dirname($a_dir);
141  $last_dirname = '';
142  while($last_dirname != $a_dir)
143  {
144  array_unshift($dirs, $a_dir);
145  $last_dirname = $a_dir;
146  $a_dir = dirname($a_dir);
147  }
148 
149  // find the first existing dir
150  $reverse_paths = array_reverse($dirs, TRUE);
151  $found_index = -1;
152  foreach ($reverse_paths as $key => $value)
153  {
154  if ($found_index == -1)
155  {
156  if (is_dir($value))
157  {
158  $found_index = $key;
159  }
160  }
161  }
162 
163  umask(0000);
164  foreach ($dirs as $dirindex => $dir)
165  {
166  // starting with the longest existing path
167  if ($dirindex >= $found_index)
168  {
169  if (! file_exists($dir))
170  {
171  if (strcmp(substr($dir,strlen($dir)-1,1),"/") == 0)
172  {
173  // on some systems there is an error when there is a slash
174  // at the end of a directory in mkdir, see Mantis #2554
175  $dir = substr($dir,0,strlen($dir)-1);
176  }
177 
178  if (! mkdir($dir, $umask))
179  {
180  error_log("Can't make directory: $dir");
181  return false;
182  }
183  }
184  elseif (! is_dir($dir))
185  {
186  error_log("$dir is not a directory");
187  return false;
188  }
189  else
190  {
191  // get umask of the last existing parent directory
192  $umask = fileperms($dir);
193  }
194  }
195  }
196  return true;
197  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTrailingPathSeparators()

ilUpdateUtils::removeTrailingPathSeparators (   $path)

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

References $path.

Referenced by ilFileSystemStorage\create(), ilFSStorageEvent\createDirectory(), and ilFileSystemStorage\init().

41  {
42  $path = preg_replace("/[\/\\\]+$/", "", $path);
43  return $path;
44  }
$path
Definition: aliased.php:25
+ Here is the caller graph for this function:

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