~yoboy-leguesh/ubuntu-fr-doc/maj20150810a

« back to all changes in this revision

Viewing changes to inc/TarLib.class.php

  • Committer: YoBoY
  • Date: 2015-11-11 10:05:14 UTC
  • Revision ID: yoboy.leguesh@gmail.com-20151111100514-bw7p06lrhban4g2t
Mise à jour vers Dokuwiki 2015-08-10a avec nos patchs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
/**
4
 
 * This is a compatibility wrapper around the new Tar class
5
 
 *
6
 
 * Use of this library is strongly discouraged. Only basic extraction is wrapped,
7
 
 * everything else will fail.
8
 
 *
9
 
 * @deprecated 2012-11-06
10
 
 */
11
 
class TarLib {
12
 
 
13
 
    const   COMPRESS_GZIP      = 1;
14
 
    const   COMPRESS_BZIP      = 2;
15
 
    const   COMPRESS_AUTO      = 3;
16
 
    const   COMPRESS_NONE      = 0;
17
 
    const   TARLIB_VERSION     = '1.2';
18
 
    const   FULL_ARCHIVE       = -1;
19
 
    const   ARCHIVE_DYNAMIC    = 0;
20
 
    const   ARCHIVE_RENAMECOMP = 5;
21
 
    const   COMPRESS_DETECT    = -1;
22
 
 
23
 
    private $file = '';
24
 
    private $tar;
25
 
 
26
 
    public $_result = true;
27
 
 
28
 
    function __construct($file, $comptype = TarLib::COMPRESS_AUTO, $complevel = 9) {
29
 
        if(!$file) $this->error('__construct', '$file');
30
 
 
31
 
        $this->file = $file;
32
 
        switch($comptype) {
33
 
            case TarLib::COMPRESS_AUTO:
34
 
            case TarLib::COMPRESS_DETECT:
35
 
                $comptype = Tar::COMPRESS_AUTO;
36
 
                break;
37
 
            case TarLib::COMPRESS_GZIP:
38
 
                $comptype = Tar::COMPRESS_GZIP;
39
 
                break;
40
 
            case TarLib::COMPRESS_BZIP:
41
 
                $comptype = Tar::COMPRESS_BZIP;
42
 
                break;
43
 
            default:
44
 
                $comptype = Tar::COMPRESS_NONE;
45
 
        }
46
 
 
47
 
        $this->complevel = $complevel;
48
 
 
49
 
        try {
50
 
            $this->tar = new Tar();
51
 
            $this->tar->open($file, $comptype);
52
 
        } catch(Exception $e) {
53
 
            $this->_result = false;
54
 
        }
55
 
    }
56
 
 
57
 
    function Extract($p_what = TarLib::FULL_ARCHIVE, $p_to = '.', $p_remdir = '', $p_mode = 0755) {
58
 
        if($p_what != TarLib::FULL_ARCHIVE) {
59
 
            $this->error('Extract', 'Ep_what');
60
 
            return 0;
61
 
        }
62
 
 
63
 
        try {
64
 
            $this->tar->extract($p_to, $p_remdir);
65
 
        } catch(Exception $e) {
66
 
            return 0;
67
 
        }
68
 
        return 1;
69
 
    }
70
 
 
71
 
    function error($func, $param = '') {
72
 
        $error = 'TarLib is deprecated and should no longer be used.';
73
 
 
74
 
        if($param) {
75
 
            $error .= "In this compatibility wrapper, the function '$func' does not accept your value for".
76
 
                "the parameter '$param' anymore.";
77
 
        } else {
78
 
            $error .= "The function '$func' no longer exists in this compatibility wrapper.";
79
 
        }
80
 
 
81
 
        msg($error, -1);
82
 
    }
83
 
 
84
 
    function __call($name, $arguments) {
85
 
        $this->error($name);
86
 
    }
87
 
}
 
 
b'\\ No newline at end of file'