Core
3.2
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
Examples
File List
Globals
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
$usage
Definition:
vault_init.php:22
$pubdir
global $pubdir
Definition:
vault_init.php:18
$dirname
$dirname
Definition:
vault_init.php:25
$fsname
$fsname
Definition:
vault_init.php:26
VAULT_DMODE
const VAULT_DMODE
Definition:
Class.VaultFile.php:19
$appl
global $appl
Definition:
vault_init.php:18
$q
$q
Definition:
FullFileIndex.php:38
print
print
Definition:
checklist.php:49
QueryDb
Definition:
Class.QueryDb.php:19
$size_in_bytes
$size_in_bytes
Definition:
vault_init.php:27
VaultFile
Definition:
Class.VaultFile.php:21
$dbaccess
$dbaccess
Definition:
vault_init.php:30
$vf
$vf
Definition:
geticon.php:28
$err
$err
Definition:
vault_init.php:31
ApiUsage
Verify arguments for wsh programs.
Definition:
Class.ApiUsage.php:28
← centre documentaire
© anakeen