[ Index ]

PHP Cross Reference of PHK Manager

title

Body

[close]

/PHK/Virtual/ -> Dir.php (source)

   1  <?php
   2  //=============================================================================
   3  //
   4  // Copyright Francois Laupretre <phk@tekwire.net>
   5  //
   6  //   Licensed under the Apache License, Version 2.0 (the "License");
   7  //   you may not use this file except in compliance with the License.
   8  //   You may obtain a copy of the License at
   9  //
  10  //       http://www.apache.org/licenses/LICENSE-2.0
  11  //
  12  //   Unless required by applicable law or agreed to in writing, software
  13  //   distributed under the License is distributed on an "AS IS" BASIS,
  14  //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15  //   See the License for the specific language governing permissions and
  16  //   limitations under the License.
  17  //
  18  //=============================================================================
  19  /**
  20  * @copyright Francois Laupretre <phk@tekwire.net>
  21  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, V 2.0
  22  * @category PHK
  23  * @package PHK
  24  *///==========================================================================
  25  
  26  namespace PHK\Virtual {
  27  
  28  if (!class_exists('PHK\Virtual\Dir',false))
  29  {
  30  //============================================================================
  31  /**
  32  * Virtual directory
  33  *
  34  * API status: Private
  35  * Included in the PHK PHP runtime: Yes
  36  * Implemented in the extension: No
  37  *///==========================================================================
  38  
  39  class Dir extends Node
  40  {
  41  
  42  private $children; // array of basenames
  43  
  44  //---
  45  
  46  public function type() { return 'dir'; }
  47  public function mode() { return 040555; }
  48  public function size() { return count($this->children); }
  49  public function getNeededExtensions() {}
  50  
  51  //---
  52  
  53  public function display($html,$link)
  54  {
  55  $path=$this->path;
  56  if ($path=='') $path='/';
  57  
  58  if ($html) echo '<tr><td nowrap colspan=4>&nbsp;<b><i>'.$path
  59          .'</i></b></td></tr>';
  60  else echo "D      $path\n";
  61  }
  62  
  63  //---
  64  
  65  public function getDir()
  66  {
  67  return $this->children;
  68  }
  69  
  70  //---
  71  
  72  public function dump($base)
  73  {
  74  $path=$base.$this->path;
  75  if (mkdir($path)===false) throw new \Exception($path.': cannot create directory');
  76  }
  77  
  78  //---
  79  
  80  public function import($edata)
  81  {
  82  $this->children=explode(';',parent::import($edata));
  83  }
  84  
  85  //---
  86  
  87  public function __construct($path,$tree)
  88  {
  89  parent::__construct($path,$tree);
  90  
  91  $this->children=array();
  92  }
  93  
  94  //---
  95  
  96  public function subpath($name)
  97  {
  98  return $this->path.'/'.$name;
  99  }
 100  
 101  // <CREATOR> //---------------
 102  
 103  public function addChild($name)
 104  {
 105  if (array_search($name,$this->children)===false) $this->children[]=$name;
 106  }
 107  
 108  //---
 109  
 110  public function removeChild($name)
 111  {
 112  if (($key=array_search($name,$this->children))===false)
 113      unset ($this->children[$key]);
 114  }
 115  
 116  //---
 117  
 118  public function export(\PHK\Build\Creator $phk,\PHK\Build\DataStacker $stacker,$map)
 119  {
 120  return $this->nodeExport(implode(';',$this->children));
 121  }
 122  
 123  // </CREATOR> //---------------
 124  
 125  //---
 126  } // End of class
 127  //===========================================================================
 128  } // End of class_exists
 129  //===========================================================================
 130  } // End of namespace
 131  //===========================================================================
 132  ?>


Generated: Thu Jun 4 18:33:15 2015 Cross-referenced by PHPXref 0.7.1