Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
 
4
/**
5
 * Base class for all the archive readers (that read from a single file)
6
 *
7
 * PHP versions 4 and 5
8
 *
9
 * This library is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 of the License, or (at your option) any later version.
13
 *
14
 * This library is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with this library; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
22
 *
23
 * @category   File Formats
24
 * @package    File_Archive
25
 * @author     Vincent Lascaux <vincentlascaux@php.net>
26
 * @copyright  1997-2005 The PHP Group
27
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL
28
 * @version    CVS: $Id: Archive.php,v 1.12 2005/05/23 19:25:24 vincentlascaux Exp $
29
 * @link       http://pear.php.net/package/File_Archive
30
 */
31
 
32
require_once "File/Archive/Reader.php";
33
 
34
/**
35
 * Base class for all the archive readers (that read from a single file)
36
 */
37
class File_Archive_Reader_Archive extends File_Archive_Reader
38
{
39
    /**
40
     * @var    File_Archive_Reader Single file source that contains the archive
41
     *         to uncompress
42
     * @access protected
43
     */
44
    var $source = null;
45
 
46
    /**
47
     * @var    bool Indicate whether the $source is currently opened
48
     * @access private
49
     */
50
    var $sourceOpened = false;
51
 
52
    /**
53
     * The source was let in this state at the end
54
     *
55
     * @var    bool Indicate whether the $source was given opened
56
     * @access private
57
     */
58
    var $sourceInitiallyOpened;
59
 
60
//ABSTRACT
61
    /**
62
     * @see File_Archive_Reader::next()
63
     *
64
     * Open the source if necessary
65
     */
66
    function next()
67
    {
68
        if (!$this->sourceOpened && ($error = $this->source->next()) !== true) {
69
            return $error;
70
        }
71
 
72
        $this->sourceOpened = true;
73
        return true;
74
    }
75
 
76
//PUBLIC
77
    function File_Archive_Reader_Archive(&$source, $sourceOpened = false)
78
    {
79
        $this->source =& $source;
80
        $this->sourceOpened = $this->sourceInitiallyOpened = $sourceOpened;
81
    }
82
    /**
83
     * Close the source if it was given closed in the constructor
84
     *
85
     * @see File_Archive_Reader::close()
86
     */
87
    function close()
88
    {
89
        if (!$this->sourceInitiallyOpened && $this->sourceOpened) {
90
            $this->sourceOpened = false;
91
            if ($this->source !== null) {
92
                return $this->source->close();
93
            }
94
        }
95
    }
96
}
97
 
98
?>