OLE
[ class tree: OLE ] [ index: OLE ] [ all elements ]

Source for file File.php

Documentation is available at File.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Xavier Noguer <xnoguer@php.net>                              |
  17. // | Based on OLE::Storage_Lite by Kawai, Takanori                        |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: File.php,v 1.11 2007/02/13 21:00:42 schmidt Exp $
  21.  
  22.  
  23. require_once api_get_path(LIBRARY_PATH).'pear/OLE/PPS.php';
  24.  
  25. /**
  26. * Class for creating File PPS's for OLE containers
  27. *
  28. @author   Xavier Noguer <xnoguer@php.net>
  29. @category Structures
  30. @package  OLE
  31. */
  32. class OLE_PPS_File extends OLE_PPS
  33. {
  34.     /**
  35.     * The temporary dir for storing the OLE file
  36.     * @var string 
  37.     */
  38.     var $_tmp_dir;
  39.  
  40.     /**
  41.     * The constructor
  42.     *
  43.     * @access public
  44.     * @param string $name The name of the file (in Unicode)
  45.     * @see OLE::Asc2Ucs()
  46.     */
  47.     function OLE_PPS_File($name)
  48.     {
  49.         $this->_tmp_dir = '';
  50.         $this->OLE_PPS(
  51.             null
  52.             $name,
  53.             OLE_PPS_TYPE_FILE,
  54.             null,
  55.             null,
  56.             null,
  57.             null,
  58.             null,
  59.             '',
  60.             array());
  61.     }
  62.  
  63.     /**
  64.     * Sets the temp dir used for storing the OLE file
  65.     *
  66.     * @access public
  67.     * @param string $dir The dir to be used as temp dir
  68.     * @return true if given dir is valid, false otherwise
  69.     */
  70.     function setTempDir($dir)
  71.     {
  72.         if (is_dir($dir)) {
  73.             $this->_tmp_dir = $dir;
  74.             return true;
  75.         }
  76.         return false;
  77.     }
  78.  
  79.     /**
  80.     * Initialization method. Has to be called right after OLE_PPS_File().
  81.     *
  82.     * @access public
  83.     * @return mixed true on success. PEAR_Error on failure
  84.     */
  85.     function init()
  86.     {
  87.         $this->_tmp_filename tempnam($this->_tmp_dir"OLE_PPS_File");
  88.         $fh @fopen($this->_tmp_filename"w+b");
  89.         if ($fh == false{
  90.             return $this->raiseError("Can't create temporary file");
  91.         }
  92.         $this->_PPS_FILE $fh;
  93.         if ($this->_PPS_FILE{
  94.             fseek($this->_PPS_FILE0);
  95.         }
  96.  
  97.         return true;
  98.     }
  99.     
  100.     /**
  101.     * Append data to PPS
  102.     *
  103.     * @access public
  104.     * @param string $data The data to append
  105.     */
  106.     function append($data)
  107.     {
  108.         if ($this->_PPS_FILE{
  109.             fwrite($this->_PPS_FILE$data);
  110.         else {
  111.             $this->_data .= $data;
  112.         }
  113.     }
  114.  
  115.     /**
  116.      * Returns a stream for reading this file using fread() etc.
  117.      * @return  resource  a read-only stream
  118.      */
  119.     function getStream()
  120.     {
  121.         $this->ole->getStream($this);
  122.     }
  123. }
  124. ?>

Documentation generated on Thu, 12 Jun 2008 13:28:34 -0500 by phpDocumentor 1.4.1