Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Lib.FileDir.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Set of usefull system file functions
9  *
10  * @author Anakeen 2000
11  * @version $Id: Lib.FileDir.php,v 1.3 2004/07/29 09:28:34 yannick Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage CORE
15  */
16 /**
17  */
18 function create_dir($dir, $access, $owner = "", $group = "")
19 {
20  clearstatcache();
21  if (!file_exists($dir)) {
22  if (!file_exists(dirname($dir))) create_dir(dirname($dir) , "$access", $owner, $group);
23  $cmd = "mkdir(\"" . $dir . "\"," . $access . ");";
24  eval($cmd);
25  if ($owner != "") chown($dir, $owner);
26  if ($group != "") chgrp($dir, $group);
27  }
28 }
29 
30 function create_file($file, $access, $owner = "", $group = "")
31 {
32  clearstatcache();
33  if (!file_exists($file)) {
34  if (!file_exists(dirname($file))) create_dir(dirname($file) , "$access", $owner, $group);
35  touch($file);
36  if ($owner != "") chown($file, $owner);
37  if ($group != "") chgrp($file, $group);
38  }
39 }
40 
41 function install_file($from, $to, $access, $owner = "", $group = "")
42 {
43  clearstatcache();
44  if (file_exists($from)) {
45  create_dir(dirname($to) , "$access", $owner, $group);
46  copy($from, $to);
47  $cmd = "chmod(\"" . $to . "\"," . $access . ");";
48  eval($cmd);
49  chmod($to, $access);
50  if ($owner != "") chown($dir, $owner);
51  if ($group != "") chgrp($dir, $group);
52  }
53 }
54 
55 function remove_dir($dir)
56 {
57  $cmd = sprintf("rm -rf %s", escapeshellarg($dir));
58  system($cmd);
59 }
60 ?>
← centre documentaire © anakeen - published under CC License - Dynacase