Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
vault_init.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Initialisation of the FREEDOM VAULT based on the VAULT/FREEDOM.vault file
8  *
9  * create all sub-directories where files will be inserted by the VAULT application
10  * @author Anakeen
11  * @version $Id: vault_init.php,v 1.1 2007/02/19 16:25:40 marc Exp $
12  * @package FDL
13  * @subpackage WSH
14  */
15 /**
16  */
17 
18 include_once ("VAULT/Class.VaultFile.php");
19 include_once ("FDL/Lib.Util.php");
20 global $pubdir, $appl;
21 
22 $usage = new ApiUsage();
23 
24 $usage->setDefinitionText("Initialisation of the FREEDOM VAULT based on the VAULT/FREEDOM.vault file");
25 $dirname = $usage->addOptionalParameter("path", "path to vault", null, "$pubdir/vaultfs");
26 $fsname = $usage->addOptionalParameter("name", "Fs name", null, "FREEDOM");
27 $size_in_bytes = $usage->addOptionalParameter("size", "Vault size", null, 500 * 1024 * 1024); // 500Mb
28 $usage->verify();
29 
30 $dbaccess = $appl->dbaccess;
31 $err = "";
32 if (!is_dir($dirname)) {
33  if (is_dir(dirname($dirname))) {
34  print sprintf(_("create directory %s\n") , $dirname);
35  mkdir($dirname . "/", VAULT_DMODE);
36  }
37 }
38 if (!is_dir($dirname)) {
39 
40  $err = sprintf(_("cannot create directory %s\nParent directory must be create before") , $dirname);
41 }
42 if ($err == "") {
43  $vf = new VaultFile($dbaccess);
44  // print_r2($vf);
45  $q = new QueryDb($dbaccess, "VaultDiskFsStorage");
46  $q->AddQuery("r_path='" . pg_escape_string(trim($dirname)) . "'");
47  $l = $q->Query(0, 0, "TABLE");
48  if ($q->nb == 0) {
49  $err = $vf->storage->fs->createArch($size_in_bytes, $dirname, $fsname);
50  if ($err != "") $err = sprintf(_("cannot create %s: %s\n") , $dirname, $err);
51  else print sprintf(_("vault %s created.\n") , $dirname);
52  } else {
53  $err = sprintf(_("vault already created %s: aborted\n") , $dirname);
54  }
55 }
56 if ($err) print sprintf(_("ERROR %s\n") , $err);
$usage
Definition: vault_init.php:22
global $pubdir
Definition: vault_init.php:18
$dirname
Definition: vault_init.php:25
$fsname
Definition: vault_init.php:26
const VAULT_DMODE
global $appl
Definition: vault_init.php:18
print
Definition: checklist.php:49
$size_in_bytes
Definition: vault_init.php:27
$dbaccess
Definition: vault_init.php:30
$vf
Definition: geticon.php:28
$err
Definition: vault_init.php:31
Verify arguments for wsh programs.
← centre documentaire © anakeen