~ubuntu-branches/ubuntu/saucy/horde3/saucy

« back to all changes in this revision

Viewing changes to lib/VFS/ISOWriter.php

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-05-04 23:08:08 UTC
  • Revision ID: james.westby@ubuntu.com-20050504230808-p4hf3hk28o3v7wir
Tags: upstream-3.0.4
ImportĀ upstreamĀ versionĀ 3.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
require_once 'PEAR.php';
 
4
 
 
5
/**
 
6
 * VFS API for abstracted creation of ISO (CD-ROM) filesystems.
 
7
 *
 
8
 * $Horde: framework/VFS_ISOWriter/ISOWriter.php,v 1.1.8.1 2005/01/03 12:19:21 jan Exp $
 
9
 *
 
10
 * Copyright 2004-2005 Cronosys, LLC <http://www.cronosys.com/>
 
11
 *
 
12
 * See the enclosed file COPYING for license information (LGPL). If you
 
13
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 
14
 *
 
15
 * @author  Jason M. Felice <jfelice@cronosys.com>
 
16
 * @version $Revision: 1.1.8.1 $
 
17
 * @package VFS_ISO
 
18
 * @since   Horde 3.0
 
19
 */
 
20
class VFS_ISOWriter {
 
21
 
 
22
    /**
 
23
     * A VFS object used for reading the source files
 
24
     *
 
25
     * @var object $_sourceVfs
 
26
     */
 
27
    var $_sourceVfs = null;
 
28
 
 
29
    /**
 
30
     * A VFS object used for writing the ISO image
 
31
     *
 
32
     * @var object $_targetVfs
 
33
     */
 
34
    var $_targetVfs = null;
 
35
 
 
36
    /**
 
37
     * Hash containing connection parameters.
 
38
     *
 
39
     * @var array $_params
 
40
     */
 
41
    var $_params = array();
 
42
 
 
43
    /**
 
44
     * Constructs a new VFS_ISOWriter object
 
45
     *
 
46
     * @access public
 
47
     *
 
48
     * @param array $params           A hash containing parameters.
 
49
     */
 
50
    function VFS_ISOWriter(&$sourceVfs, &$targetVfs, $params)
 
51
    {
 
52
        $this->_sourceVfs = &$sourceVfs;
 
53
        $this->_targetVfs = &$targetVfs;
 
54
        $this->_params = $params;
 
55
    }
 
56
 
 
57
    /**
 
58
     * Create the ISO image
 
59
     *
 
60
     * @abstract
 
61
     * @access public
 
62
     *
 
63
     * @return mixed        Null or PEAR_Error on failure.
 
64
     */
 
65
    function process()
 
66
    {
 
67
        return PEAR::raiseError(_("Not implemented."));
 
68
    }
 
69
 
 
70
    /**
 
71
     * Attempt to create a concrete VFS_ISOWriter subclass.
 
72
     *
 
73
     * This method uses its parameters and checks the system to determine
 
74
     * the most appropriate subclass to use for building ISO images.  If
 
75
     * none is found, an error is raised.
 
76
     *
 
77
     * @access public
 
78
     *
 
79
     * @param object &$sourceVfs      Reference to the VFS object from which
 
80
     *                                the files will be read to create the
 
81
     *                                ISO image.
 
82
     * @param object &$targetVfs      Reference to the VFS object to which the
 
83
     *                                ISO image will be written.
 
84
     * @param array $params           Hash of parameters for creating the
 
85
     *                                image:
 
86
     *              'sourceRoot' =>     A directory in the source VFS for
 
87
     *                                  files to be read from for the image.
 
88
     *              'targetFile' =>     Path and filename of the ISO file to
 
89
     *                                  write into the target VFS.
 
90
     *
 
91
     * @return object                 A newly created concrete VFS_ISOWriter
 
92
     *                                subclass, or a PEAR_Error on an error.
 
93
     */
 
94
    function &factory(&$sourceVfs, &$targetVfs, $params)
 
95
    {
 
96
        if (empty($params['targetFile'])) {
 
97
            return PEAR::raiseError(_("Cannot proceed without 'targetFile' parameter."));
 
98
        }
 
99
        if (empty($params['sourceRoot'])) {
 
100
            $params['sourceRoot'] = '/';
 
101
        }
 
102
 
 
103
        /* Right now, mkisofs is the only driver, but make sure we can
 
104
         * support it. */
 
105
        require_once dirname(__FILE__) . '/ISOWriter/mkisofs.php';
 
106
        if (VFS_ISOWriter_mkisofs::strategyAvailable()) {
 
107
            return $ret = &new VFS_ISOWriter_mkisofs($sourceVfs, $targetVfs,
 
108
                                                     $params);
 
109
        }
 
110
 
 
111
        return PEAR::raiseError(_("No available strategy for making ISO images."));
 
112
    }
 
113
 
 
114
}