File: ISOWriter.php

package info (click to toggle)
horde3 3.0.4-4sarge7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 15,980 kB
  • ctags: 16,295
  • sloc: php: 68,726; xml: 2,382; sql: 498; makefile: 74; sh: 63; pascal: 6
file content (114 lines) | stat: -rw-r--r-- 3,561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php

require_once 'PEAR.php';

/**
 * VFS API for abstracted creation of ISO (CD-ROM) filesystems.
 *
 * $Horde: framework/VFS_ISOWriter/ISOWriter.php,v 1.1.8.1 2005/01/03 12:19:21 jan Exp $
 *
 * Copyright 2004-2005 Cronosys, LLC <http://www.cronosys.com/>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Jason M. Felice <jfelice@cronosys.com>
 * @version $Revision: 1.1.8.1 $
 * @package VFS_ISO
 * @since   Horde 3.0
 */
class VFS_ISOWriter {

    /**
     * A VFS object used for reading the source files
     *
     * @var object $_sourceVfs
     */
    var $_sourceVfs = null;

    /**
     * A VFS object used for writing the ISO image
     *
     * @var object $_targetVfs
     */
    var $_targetVfs = null;

    /**
     * Hash containing connection parameters.
     *
     * @var array $_params
     */
    var $_params = array();

    /**
     * Constructs a new VFS_ISOWriter object
     *
     * @access public
     *
     * @param array $params           A hash containing parameters.
     */
    function VFS_ISOWriter(&$sourceVfs, &$targetVfs, $params)
    {
        $this->_sourceVfs = &$sourceVfs;
        $this->_targetVfs = &$targetVfs;
        $this->_params = $params;
    }

    /**
     * Create the ISO image
     *
     * @abstract
     * @access public
     *
     * @return mixed        Null or PEAR_Error on failure.
     */
    function process()
    {
        return PEAR::raiseError(_("Not implemented."));
    }

    /**
     * Attempt to create a concrete VFS_ISOWriter subclass.
     *
     * This method uses its parameters and checks the system to determine
     * the most appropriate subclass to use for building ISO images.  If
     * none is found, an error is raised.
     *
     * @access public
     *
     * @param object &$sourceVfs      Reference to the VFS object from which
     *                                the files will be read to create the
     *                                ISO image.
     * @param object &$targetVfs      Reference to the VFS object to which the
     *                                ISO image will be written.
     * @param array $params           Hash of parameters for creating the
     *                                image:
     *              'sourceRoot' =>     A directory in the source VFS for
     *                                  files to be read from for the image.
     *              'targetFile' =>     Path and filename of the ISO file to
     *                                  write into the target VFS.
     *
     * @return object                 A newly created concrete VFS_ISOWriter
     *                                subclass, or a PEAR_Error on an error.
     */
    function &factory(&$sourceVfs, &$targetVfs, $params)
    {
        if (empty($params['targetFile'])) {
            return PEAR::raiseError(_("Cannot proceed without 'targetFile' parameter."));
        }
        if (empty($params['sourceRoot'])) {
            $params['sourceRoot'] = '/';
        }

        /* Right now, mkisofs is the only driver, but make sure we can
         * support it. */
        require_once dirname(__FILE__) . '/ISOWriter/mkisofs.php';
        if (VFS_ISOWriter_mkisofs::strategyAvailable()) {
            return $ret = &new VFS_ISOWriter_mkisofs($sourceVfs, $targetVfs,
                                                     $params);
        }

        return PEAR::raiseError(_("No available strategy for making ISO images."));
    }

}