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

Source for file file.php

Documentation is available at file.php

  1. <?php
  2. /**
  3.  * VFS implementation for a standard filesystem.
  4.  *
  5.  * Required parameters:<pre>
  6.  *   'vfsroot'  The root path</pre>
  7.  *
  8.  * Note: The user that your webserver runs as (commonly 'nobody',
  9.  * 'apache', or 'www-data') MUST have read/write permission to the
  10.  * directory you specify as the 'vfsroot'.
  11.  *
  12.  * $Horde: framework/VFS/VFS/file.php,v 1.93 2006/03/30 08:03:09 selsky Exp $
  13.  *
  14.  * Copyright 2002-2006 Chuck Hagenbuch <chuck@horde.org>
  15.  *
  16.  * See the enclosed file COPYING for license information (LGPL). If you
  17.  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  18.  *
  19.  * @author  Chuck Hagenbuch
  20.  * @since   Horde 2.2
  21.  * @package VFS
  22.  */
  23. class VFS_file extends VFS {
  24.  
  25.     /**
  26.      * List of permissions and if they can be changed in this VFS
  27.      * backend.
  28.      *
  29.      * @var array 
  30.      */
  31.     var $_permissions = array(
  32.         'owner' => array('read' => true'write' => true'execute' => true),
  33.         'group' => array('read' => true'write' => true'execute' => true),
  34.         'all'   => array('read' => true'write' => true'execute' => true)
  35.     );
  36.  
  37.     /**
  38.      * Constructs a new Filesystem based VFS object.
  39.      *
  40.      * @param array $params  A hash containing connection parameters.
  41.      */
  42.     function VFS_file($params = array())
  43.     {
  44.         parent::VFS($params);
  45.  
  46.         if (!empty($this->_params['vfsroot'])) {
  47.             if (substr($this->_params['vfsroot']-1== '/' ||
  48.                 substr($this->_params['vfsroot']-1== '\\'{
  49.                 $this->_params['vfsroot'substr($this->_params['vfsroot']0strlen($this->_params['vfsroot']- 1);
  50.             }
  51.         }
  52.     }
  53.  
  54.     /**
  55.      * Retrieves the filesize from the VFS.
  56.      *
  57.      * @param string $path  The pathname to the file.
  58.      * @param string $name  The filename to retrieve.
  59.      *
  60.      * @return integer The file size.
  61.      */
  62.     function size($path$name)
  63.     {
  64.         return filesize($this->_getNativePath($path$name));
  65.     }
  66.  
  67.     /**
  68.      * Retrieve a file from the VFS.
  69.      *
  70.      * @param string $path  The pathname to the file.
  71.      * @param string $name  The filename to retrieve.
  72.      *
  73.      * @return string  The file data.
  74.      */
  75.     function read($path$name)
  76.     {
  77.         $file $this->_getNativePath($path$name);
  78.         if (function_exists('file_get_contents')) {
  79.             $data @file_get_contents($file);
  80.             if ($data === false{
  81.                 return PEAR::raiseError(_("Unable to open VFS file."));
  82.             }
  83.         else {
  84.             $fp @fopen($file'rb');
  85.             if (!$fp{
  86.                 return PEAR::raiseError(_("Unable to open VFS file."));
  87.             }
  88.             $filesize filesize($file);
  89.             if ($filesize == 0{
  90.                 $data '';
  91.             else {
  92.                 $data fread($fp$filesize);
  93.             }
  94.             fclose($fp);
  95.         }
  96.  
  97.         return $data;
  98.     }
  99.  
  100.     /**
  101.      * Retrieves a part of a file from the VFS. Particularly useful when
  102.      * reading large files which would exceed the PHP memory limits if they
  103.      * were stored in a string.
  104.      *
  105.      * @abstract
  106.      *
  107.      * @param string  $path       The pathname to the file.
  108.      * @param string  $name       The filename to retrieve.
  109.      * @param integer $offset     The offset of the part. (The new offset will
  110.      *                             be stored in here).
  111.      * @param integer $length     The length of the part. If the length = -1,
  112.      *                             the whole part after the offset is retrieved.
  113.      *                             If more bytes are given as exists after the
  114.      *                             given offset. Only the available bytes are
  115.      *                             read.
  116.      * @param integer $remaining  The bytes that are left, after the part that
  117.      *                             is retrieved.
  118.      *
  119.      * @return string The file data.
  120.      */
  121.     function readByteRange($path$name&$offset$length = -1&$remaining)
  122.     {
  123.         if ($offset < 0{
  124.             return PEAR::raiseError(sprintf(_("Wrong offset %d while reading a VFS file.")$offset));
  125.         }
  126.  
  127.         // Calculate how many bytes MUST be read, so the remainging
  128.         // bytes and the new offset can be calculated correctly.
  129.         $file $this->_getNativePath($path$name);
  130.         $size filesize ($file);
  131.         if ($length == -1 || (($length $offset$size)) {
  132.             $length $size $offset;
  133.         }
  134.         if ($remaining < 0{
  135.             $remaining = 0;
  136.         }
  137.  
  138.         $fp @fopen($file'rb');
  139.         if (!$fp{
  140.             return PEAR::raiseError(_("Unable to open VFS file."));
  141.         }
  142.         fseek($fp$offset);
  143.         $data fread($fp$length);
  144.         $offset ftell($fp);
  145.         $remaining $size $offset;
  146.  
  147.         fclose($fp);
  148.  
  149.         return $data;
  150.     }
  151.  
  152.     /**
  153.      * Store a file in the VFS, with the data copied from a temporary
  154.      * file.
  155.      *
  156.      * @param string $path         The path to store the file in.
  157.      * @param string $name         The filename to use.
  158.      * @param string $tmpFile      The temporary file containing the data to be
  159.      *                              stored.
  160.      * @param boolean $autocreate  Automatically create directories?
  161.      *
  162.      * @return mixed  True on success or a PEAR_Error object on failure.
  163.      */
  164.     function write($path$name$tmpFile$autocreate = true)
  165.     {
  166.         if (!@is_dir($this->_getNativePath($path))) {
  167.             if ($autocreate{
  168.                 $res $this->autocreatePath($path);
  169.                 if (is_a($res'PEAR_Error')) {
  170.                     return $res;
  171.                 }
  172.             else {
  173.                 return PEAR::raiseError(_("VFS directory does not exist."));
  174.             }
  175.         }
  176.  
  177.         $res $this->_checkQuotaWrite('file'$tmpFile);
  178.         if (is_a($res'PEAR_Error')) {
  179.             return $res;
  180.         }
  181.  
  182.         // Since we already have the data in a file, don't read it
  183.         // into PHP's memory at all - just copy() it to the new
  184.         // location. We leave it to the caller to clean up the
  185.         // temporary file, so we don't use rename().
  186.         if (@copy($tmpFile$this->_getNativePath($path$name))) {
  187.             return true;
  188.         else {
  189.             return PEAR::raiseError(_("Unable to write VFS file (copy() failed)."));
  190.         }
  191.     }
  192.  
  193.     /**
  194.      * Moves a file in the database and the file system.
  195.      *
  196.      * @param string $path         The path to store the file in.
  197.      * @param string $name         The filename to use.
  198.      * @param string $dest         The destination of the file.
  199.      * @param boolean $autocreate  Automatically create directories?
  200.      *
  201.      * @return mixed  True on success or a PEAR_Error object on failure.
  202.      */
  203.     function move($path$name$dest$autocreate = false)
  204.     {
  205.         $orig $this->_getNativePath($path$name);
  206.         if (preg_match('|^' preg_quote($orig'[$/]|'$dest)) {
  207.             return PEAR::raiseError(_("Cannot move file(s) - destination is within source."));
  208.         }
  209.  
  210.         if ($autocreate{
  211.             $result $this->autocreatePath($dest);
  212.             if (is_a($result'PEAR_Error')) {
  213.                 return $result;
  214.             }
  215.         }
  216.  
  217.         $fileCheck $this->listFolder($destfalse);
  218.         if (is_a($fileCheck'PEAR_Error')) {
  219.             return $fileCheck;
  220.         }
  221.         foreach ($fileCheck as $file{
  222.             if ($file['name'== $name{
  223.                 return PEAR::raiseError(_("Unable to move VFS file."));
  224.             }
  225.         }
  226.  
  227.         if (!@rename($orig$this->_getNativePath($dest$name))) {
  228.             return PEAR::raiseError(_("Unable to move VFS file."));
  229.         }
  230.  
  231.         return true;
  232.     }
  233.  
  234.     /**
  235.      * Copies a file through the backend.
  236.      *
  237.      * @param string $path         The path to store the file in.
  238.      * @param string $name         The filename to use.
  239.      * @param string $dest         The destination of the file.
  240.      * @param boolean $autocreate  Automatically create directories?
  241.      *
  242.      * @return mixed  True on success or a PEAR_Error object on failure.
  243.      */
  244.     function copy($path$name$dest$autocreate = false)
  245.     {
  246.         $orig $this->_getNativePath($path$name);
  247.         if (preg_match('|^' preg_quote($orig'[$/]|'$dest)) {
  248.             return PEAR::raiseError(_("Cannot copy file(s) - source and destination are the same."));
  249.         }
  250.  
  251.         if ($autocreate{
  252.             $result $this->autocreatePath($dest);
  253.             if (is_a($result'PEAR_Error')) {
  254.                 return $result;
  255.             }
  256.         }
  257.  
  258.         $fileCheck $this->listFolder($destfalse);
  259.         if (is_a($fileCheck'PEAR_Error')) {
  260.             return $fileCheck;
  261.         }
  262.         foreach ($fileCheck as $file{
  263.             if ($file['name'== $name{
  264.                 return PEAR::raiseError(_("Unable to copy VFS file."));
  265.             }
  266.         }
  267.  
  268.         if (!@copy($orig$this->_getNativePath($dest$name))) {
  269.             return PEAR::raiseError(_("Unable to copy VFS file."));
  270.         }
  271.  
  272.         return true;
  273.     }
  274.  
  275.     /**
  276.      * Store a file in the VFS from raw data.
  277.      *
  278.      * @param string $path         The path to store the file in.
  279.      * @param string $name         The filename to use.
  280.      * @param string $data         The file data.
  281.      * @param boolean $autocreate  Automatically create directories?
  282.      *
  283.      * @return mixed  True on success or a PEAR_Error object on failure.
  284.      */
  285.     function writeData($path$name$data$autocreate = true)
  286.     {
  287.         if (!@is_dir($this->_getNativePath($path))) {
  288.             if ($autocreate{
  289.                 $res $this->autocreatePath($path);
  290.                 if (is_a($res'PEAR_Error')) {
  291.                     return $res;
  292.                 }
  293.             else {
  294.                 return PEAR::raiseError(_("VFS directory does not exist."));
  295.             }
  296.         }
  297.  
  298.         // Treat an attempt to write an empty file as a touch() call,
  299.         // since otherwise the file will not be created at all.
  300.         if (!strlen($data)) {
  301.             if (@touch($this->_getNativePath($path$name))) {
  302.                 return true;
  303.             else {
  304.                 return PEAR::raiseError(_("Unable to create empty VFS file."));
  305.             }
  306.         }
  307.  
  308.         $res $this->_checkQuotaWrite('string'$data);
  309.         if (is_a($res'PEAR_Error')) {
  310.             return $res;
  311.         }
  312.  
  313.         // Otherwise we go ahead and try to write out the file.
  314.         $fp @fopen($this->_getNativePath($path$name)'w');
  315.         if (!$fp{
  316.             return PEAR::raiseError(_("Unable to open VFS file for writing."));
  317.         }
  318.  
  319.         if (!@fwrite($fp$data)) {
  320.             return PEAR::raiseError(_("Unable to write VFS file data."));
  321.         }
  322.  
  323.         return true;
  324.     }
  325.  
  326.     /**
  327.      * Delete a file from the VFS.
  328.      *
  329.      * @param string $path  The path to store the file in.
  330.      * @param string $name  The filename to use.
  331.      *
  332.      * @return mixed  True on success or a PEAR_Error object on failure.
  333.      */
  334.     function deleteFile($path$name)
  335.     {
  336.         $res $this->_checkQuotaDelete($path$name);
  337.         if (is_a($res'PEAR_Error')) {
  338.             return $res;
  339.         }
  340.  
  341.         if (!@unlink($this->_getNativePath($path$name))) {
  342.             return PEAR::raiseError(_("Unable to delete VFS file."));
  343.         }
  344.  
  345.         return true;
  346.     }
  347.  
  348.     /**
  349.      * Delete a folder from the VFS.
  350.      *
  351.      * @param string $path        The path to delete the folder from.
  352.      * @param string $name        The foldername to use.
  353.      * @param boolean $recursive  Force a recursive delete?
  354.      *
  355.      * @return mixed True on success or a PEAR_Error object on failure.
  356.      */
  357.     function deleteFolder($path$name$recursive = false)
  358.     {
  359.         if ($recursive{
  360.             $result $this->emptyFolder($path '/' $name);
  361.             if (is_a($result'PEAR_Error')) {
  362.                 return $result;
  363.             }
  364.         else {
  365.             $list $this->listFolder($path '/' $name);
  366.             if (is_a($list'PEAR_Error')) {
  367.                 return $list;
  368.             }
  369.             if (count($list)) {
  370.                 return PEAR::raiseError(sprintf(_("Unable to delete %s, the directory is not empty"),
  371.                                                 $path '/' $name));
  372.             }
  373.         }
  374.  
  375.         if (!@rmdir($this->_getNativePath($path$name))) {
  376.             return PEAR::raiseError(_("Unable to delete VFS directory."));
  377.         }
  378.  
  379.         return true;
  380.     }
  381.  
  382.     /**
  383.      * Creates a folder on the VFS.
  384.      *
  385.      * @param string $path  The path to delete the folder from.
  386.      * @param string $name  The foldername to use.
  387.      *
  388.      * @return mixed  True on success or a PEAR_Error object on failure.
  389.      */
  390.     function createFolder($path$name)
  391.     {
  392.         if (!@mkdir($this->_getNativePath($path$name))) {
  393.             return PEAR::raiseError(_("Unable to create VFS directory."));
  394.         }
  395.  
  396.         return true;
  397.     }
  398.  
  399.     /**
  400.      * Check if a given pathname is a folder.
  401.      *
  402.      * @param string $path  The path to the folder.
  403.      * @param string $name  The file/folder name.
  404.      *
  405.      * @return boolean  True if it is a folder, false otherwise.
  406.      */
  407.     function isFolder($path$name)
  408.     {
  409.         return @is_dir($this->_getNativePath($path$name));
  410.     }
  411.  
  412.     /**
  413.      * Changes permissions for an item in the VFS.
  414.      *
  415.      * @param string $path         The path of directory of the item.
  416.      * @param string $name         The name of the item.
  417.      * @param integer $permission  The octal value of the new permission.
  418.      *
  419.      * @return mixed  True on success or a PEAR_Error object on failure.
  420.      */
  421.     function changePermissions($path$name$permission)
  422.     {
  423.         if (!@chmod($this->_getNativePath($path$name)$permission)) {
  424.             return PEAR::raiseError(sprintf(_("Unable to change permission for VFS file %s/%s.")$path$name));
  425.         }
  426.  
  427.         return true;
  428.     }
  429.  
  430.     /**
  431.      * Return a list of the contents of a folder.
  432.      *
  433.      * @param string $path       The path of the directory.
  434.      * @param mixed $filter      String/hash to filter file/dirname on.
  435.      * @param boolean $dotfiles  Show dotfiles?
  436.      * @param boolean $dironly   Show only directories?
  437.      *
  438.      * @return array  File list on success, PEAR_Error on error.
  439.      */
  440.     function _listFolder($path$filter = null$dotfiles = true,
  441.                          $dironly = false)
  442.     {
  443.         $files = array();
  444.         $path = isset($path$this->_getNativePath($path$this->_getNativePath();
  445.  
  446.         if (!@is_dir($path)) {
  447.             return PEAR::raiseError(_("Not a directory"));
  448.         }
  449.  
  450.         if (!@chdir($path)) {
  451.             return PEAR::raiseError(_("Unable to access VFS directory."));
  452.         }
  453.  
  454.         $handle opendir($path);
  455.         while (($entry readdir($handle)) !== false{
  456.             // Filter out '.' and '..' entries.
  457.             if ($entry == '.' || $entry == '..'{
  458.                 continue;
  459.             }
  460.  
  461.             // Filter out dotfiles if they aren't wanted.
  462.             if (!$dotfiles && substr($entry01== '.'{
  463.                 continue;
  464.             }
  465.  
  466.             // File name
  467.             $file['name'$entry;
  468.  
  469.             // Unix style file permissions
  470.             $file['perms'$this->_getUnixPerms(fileperms($entry));
  471.  
  472.             // Owner
  473.             $file['owner'fileowner($entry);
  474.             if (function_exists('posix_getpwuid')) {
  475.                 $owner posix_getpwuid($file['owner']);
  476.                 $file['owner'$owner['name'];
  477.             }
  478.  
  479.             // Group
  480.             $file['group'filegroup($entry);
  481.             if (function_exists('posix_getgrgid')) {
  482.                 $group posix_getgrgid($file['group']);
  483.                 $file['group'$group['name'];
  484.             }
  485.  
  486.             // Size
  487.             $file['size'filesize($entry);
  488.  
  489.             // Date
  490.             $file['date'filemtime($entry);
  491.  
  492.             // Type
  493.             if (@is_dir($entry&& !is_link($entry)) {
  494.                 $file['perms''d' $file['perms'];
  495.                 $file['type''**dir';
  496.                 $file['size'= -1;
  497.             elseif (is_link($entry)) {
  498.                 $file['perms''l' $file['perms'];
  499.                 $file['type''**sym';
  500.                 $file['link'readlink($entry);
  501.                 $file['linktype''**none';
  502.                 if (file_exists($file['link'])) {
  503.                     if (is_dir($file['link'])) {
  504.                         $file['linktype''**dir';
  505.                     elseif (is_link($file['link'])) {
  506.                         $file['linktype''**sym';
  507.                     elseif (is_file($file['link'])) {
  508.                         $ext explode('.'$file['link']);
  509.                         if (!(count($ext== 1 || ($ext[0=== '' && count($ext== 2))) {
  510.                             $file['linktype'VFS::strtolower($ext[count($ext- 1]);
  511.                         }
  512.                     }
  513.                 else {
  514.                     $file['linktype''**broken';
  515.                 }
  516.             elseif (is_file($entry)) {
  517.                 $file['perms''-' $file['perms'];
  518.                 $ext explode('.'$entry);
  519.  
  520.                 if (count($ext== 1 || (substr($file['name']01=== '.' && count($ext== 2)) {
  521.                     $file['type''**none';
  522.                 else {
  523.                     $file['type'VFS::strtolower($ext[count($ext- 1]);
  524.                 }
  525.             else {
  526.                 $file['type''**none';
  527.                 if ((fileperms($entry0xC000== 0xC000{
  528.                     $file['perms''s' $file['perms'];
  529.                 elseif ((fileperms($entry0x6000== 0x6000{
  530.                     $file['perms''b' $file['perms'];
  531.                 elseif ((fileperms($entry0x2000== 0x2000{
  532.                     $file['perms''c' $file['perms'];
  533.                 elseif ((fileperms($entry0x1000== 0x1000{
  534.                     $file['perms''p' $file['perms'];
  535.                 else {
  536.                     $file['perms''?' $file['perms'];
  537.                 }
  538.             }
  539.  
  540.             // Filtering.
  541.             if ($this->_filterMatch($filter$file['name'])) {
  542.                 unset($file);
  543.                 continue;
  544.             }
  545.             if ($dironly && $file['type'!== '**dir'{
  546.                 unset($file);
  547.                 continue;
  548.             }
  549.  
  550.             $files[$file['name']] $file;
  551.             unset($file);
  552.         }
  553.  
  554.         return $files;
  555.     }
  556.  
  557.     /**
  558.      * Returns a sorted list of folders in specified directory.
  559.      *
  560.      * @param string $path         The path of the directory to get the
  561.      *                              directory list for.
  562.      * @param mixed $filter        Hash of items to filter based on folderlist.
  563.      * @param boolean $dotfolders  Include dotfolders?
  564.      *
  565.      * @return mixed  Folder list on success or a PEAR_Error object on failure.
  566.      */
  567.     function listFolders($path ''$filter = null$dotfolders = true)
  568.     {
  569.         $conn $this->_connect();
  570.         if (is_a($conn'PEAR_Error')) {
  571.             return $conn;
  572.         }
  573.  
  574.         $folders = array();
  575.         $folders[dirname($path)= array('val' => dirname($path),
  576.                                          'abbrev' => '..',
  577.                                          'label' => '..');
  578.  
  579.         $folderList $this->listFolder($pathnull$dotfolderstrue);
  580.         if (is_a($folderList'PEAR_Error')) {
  581.             return $folderList;
  582.         }
  583.  
  584.         foreach ($folderList as $name => $files{
  585.             $folders[$name= array('val' => $path '/' $files['name'],
  586.                                     'abbrev' => $files['name'],
  587.                                     'label' => $path '/' $files['name']);
  588.         }
  589.  
  590.         ksort($folders);
  591.  
  592.         return $folders;
  593.     }
  594.  
  595.     /**
  596.      * Return Unix style perms.
  597.      *
  598.      * @access private
  599.      *
  600.      * @param integer $perms  The permissions to set.
  601.      *
  602.      * @return string  Unix style perms.
  603.      */
  604.     function _getUnixPerms($perms)
  605.     {
  606.         // Determine permissions
  607.         $owner['read']    ($perms 00400'r' '-';
  608.         $owner['write']   ($perms 00200'w' '-';
  609.         $owner['execute'($perms 00100'x' '-';
  610.         $group['read']    ($perms 00040'r' '-';
  611.         $group['write']   ($perms 00020'w' '-';
  612.         $group['execute'($perms 00010'x' '-';
  613.         $world['read']    ($perms 00004'r' '-';
  614.         $world['write']   ($perms 00002'w' '-';
  615.         $world['execute'($perms 00001'x' '-';
  616.  
  617.         // Adjust for SUID, SGID and sticky bit
  618.         if ($perms 0x800{
  619.             $owner['execute'($owner['execute'== 'x''s' 'S';
  620.         }
  621.         if ($perms 0x400{
  622.             $group['execute'($group['execute'== 'x''s' 'S';
  623.         }
  624.         if ($perms 0x200{
  625.             $world['execute'($world['execute'== 'x''t' 'T';
  626.         }
  627.  
  628.         $unixPerms $owner['read'$owner['write'$owner['execute'.
  629.                      $group['read'$group['write'$group['execute'.
  630.                      $world['read'$world['write'$world['execute'];
  631.  
  632.         return $unixPerms;
  633.     }
  634.  
  635.     /**
  636.      * Rename a file or folder in the VFS.
  637.      *
  638.      * @param string $oldpath  The old path to the file.
  639.      * @param string $oldname  The old filename.
  640.      * @param string $newpath  The new path of the file.
  641.      * @param string $newname  The new filename.
  642.      *
  643.      * @return mixed  True on success or a PEAR_Error object on failure.
  644.      */
  645.     function rename($oldpath$oldname$newpath$newname)
  646.     {
  647.         if (!@is_dir($this->_getNativePath($newpath))) {
  648.             if (is_a($res $this->autocreatePath($newpath)'PEAR_Error')) {
  649.                 return $res;
  650.             }
  651.         }
  652.  
  653.         if (!@rename($this->_getNativePath($oldpath$oldname),
  654.                      $this->_getNativePath($newpath$newname))) {
  655.             return PEAR::raiseError(sprintf(_("Unable to rename VFS file %s/%s.")$oldpath$oldname));
  656.         }
  657.  
  658.         return true;
  659.     }
  660.  
  661.     /**
  662.      * Return a full filename on the native filesystem, from a VFS
  663.      * path and name.
  664.      *
  665.      * @access private
  666.      *
  667.      * @param string $path  The VFS file path.
  668.      * @param string $name  The VFS filename.
  669.      *
  670.      * @return string  The full native filename.
  671.      */
  672.     function _getNativePath($path ''$name '')
  673.     {
  674.         $name basename($name);
  675.         if (!empty($name)) {
  676.             $name str_replace('..'''$name);
  677.             if (substr($name01!= '/'{
  678.                 $name '/' $name;
  679.             }
  680.         }
  681.  
  682.         if (!empty($path)) {
  683.             if (isset($this->_params['home']&&
  684.                 preg_match('|^~/?(.*)$|'$path$matches)) {
  685.                 $path $this->_params['home''/' $matches[1];
  686.             }
  687.  
  688.             $path str_replace('..'''$path);
  689.             if (substr($path01== '/'{
  690.                 return $this->_params['vfsroot'$path $name;
  691.             else {
  692.                 return $this->_params['vfsroot''/' $path $name;
  693.             }
  694.         else {
  695.             return $this->_params['vfsroot'$name;
  696.         }
  697.     }
  698.  
  699.     /**
  700.      * Stub to check if we have a valid connection. Makes sure that
  701.      * the vfsroot is readable.
  702.      *
  703.      * @access private
  704.      *
  705.      * @return mixed  True if vfsroot is readable, PEAR_Error if it isn't.
  706.      */
  707.     function _connect()
  708.     {
  709.         if ((@is_dir($this->_params['vfsroot']&&
  710.              @is_readable($this->_params['vfsroot'])) ||
  711.             @mkdir($this->_params['vfsroot'])) {
  712.             return true;
  713.         else {
  714.             return PEAR::raiseError(_("Unable to read the vfsroot directory."));
  715.         }
  716.     }
  717.  
  718.     /**
  719.      * Returns the size of a file.
  720.      *
  721.      * @since Horde 3.1
  722.      *
  723.      * @param string $path  The path to the file.
  724.      * @param string $name  The name of the file.
  725.      *
  726.      * @return integer  The size of the file, in bytes, or PEAR_Error on
  727.      *                   failure.
  728.      */
  729.     function getFileSize($path$name)
  730.     {
  731.         $size @filesize($this->_getNativePath($path$name));
  732.         if ($size === false{
  733.             return PEAR::raiseError(sprintf(_("Unable to check file size of \"%s/%s\".")$path$name));
  734.         }
  735.         return $size;
  736.     }
  737.  
  738. }

Documentation generated on Mon, 11 Mar 2019 14:38:59 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.