[ Index ]
 

Code source de PHP PEAR 1.4.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/PEAR/PackageFileManager/ -> Cvs.php (source)

   1  <?php
   2  //
   3  // +------------------------------------------------------------------------+
   4  // | PEAR :: Package File Manager                                           |
   5  // +------------------------------------------------------------------------+
   6  // | Copyright (c) 2003-2004 Gregory Beaver                                 |
   7  // | Email         cellog@phpdoc.org                                        |
   8  // +------------------------------------------------------------------------+
   9  // | This source file is subject to version 3.00 of the PHP License,        |
  10  // | that is available at http://www.php.net/license/3_0.txt.               |
  11  // | If you did not receive a copy of the PHP license and are unable to     |
  12  // | obtain it through the world-wide-web, please send a note to            |
  13  // | license@php.net so we can mail you a copy immediately.                 |
  14  // +------------------------------------------------------------------------+
  15  // | Portions of this code based on phpDocumentor                           |
  16  // | Web           http://www.phpdoc.org                                    |
  17  // | Mirror        http://phpdocu.sourceforge.net/                          |
  18  // +------------------------------------------------------------------------+
  19  // $Id: Cvs.php,v 1.9 2005/03/25 22:37:15 cellog Exp $
  20  //
  21  /**
  22   * @package PEAR_PackageFileManager
  23   */
  24  /**
  25   * The PEAR_PackageFileManager_File class
  26   */
  27  require_once  'PEAR/PackageFileManager/File.php';
  28  
  29  /**
  30   * Generate a file list from a CVS checkout
  31   *
  32   * Note that this will <b>NOT</b> work on a
  33   * repository, only on a checked out CVS module
  34   * @package PEAR_PackageFileManager
  35   */
  36  class PEAR_PackageFileManager_CVS extends PEAR_PackageFileManager_File {
  37      /**
  38       * List of CVS-specific files that may exist in CVS but should be
  39       * ignored when building the package's file list.
  40       * @var array
  41       * @access private
  42       */
  43      var $_cvsIgnore = array('.cvsignore');
  44  
  45      /**
  46       * Return a list of all files in the CVS repository
  47       *
  48       * This function is like {@link parent::dirList()} except
  49       * that instead of retrieving a regular filelist, it first
  50       * retrieves a listing of all the CVS/Entries files in
  51       * $directory and all of the subdirectories.  Then, it
  52       * reads the Entries file, and creates a listing of files
  53       * that are a part of the CVS repository.  No check is
  54       * made to see if they have been modified, but newly
  55       * added or removed files are ignored.
  56       * @return array list of files in a directory
  57       * @param string $directory full path to the directory you want the list of
  58       * @uses _recurDirList()
  59       * @uses _readCVSEntries()
  60       */
  61      function dirList($directory)
  62      {
  63          static $in_recursion = false;
  64          if (!$in_recursion) {
  65              // include only CVS/Entries files
  66              $this->_setupIgnore(array('*/CVS/Entries'), 0);
  67              $this->_setupIgnore(array(), 1);
  68              $in_recursion = true;
  69              $entries = parent::dirList($directory);
  70              $in_recursion = false;
  71          } else {
  72              return parent::dirList($directory);
  73          }
  74          if (!$entries || !is_array($entries)) {
  75              return PEAR_PackageFileManager::raiseError(PEAR_PACKAGEFILEMANAGER_NOCVSENTRIES, $directory);
  76          }
  77          return $this->_readCVSEntries($entries);
  78      }
  79      
  80      /**
  81       * Iterate over the CVS Entries files, and retrieve every
  82       * file in the repository
  83       * @uses _getCVSEntries()
  84       * @uses _isCVSFile()
  85       * @param array array of full paths to CVS/Entries files
  86       * @access private
  87       */
  88      function _readCVSEntries($entries)
  89      {
  90          $ret = array();
  91          $ignore = array_merge((array) $this->_options['ignore'], $this->_cvsIgnore);
  92          // implicitly ignore packagefile
  93          $ignore[] = $this->_options['packagefile'];
  94          $include = $this->_options['include'];
  95          $this->ignore = array(false, false);
  96          $this->_setupIgnore($ignore, 1);
  97          $this->_setupIgnore($include, 0);
  98          foreach($entries as $cvsentry) {
  99              $directory = @dirname(@dirname($cvsentry));
 100              if (!$directory) {
 101                  continue;
 102              }
 103              $d = $this->_getCVSEntries($cvsentry);
 104              if (!is_array($d)) {
 105                  continue;
 106              }
 107              foreach($d as $entry) {
 108                  if ($ignore) {
 109                      if ($this->_checkIgnore($this->_getCVSFileName($entry),
 110                            $directory . '/' . $this->_getCVSFileName($entry), 1)) {
 111      //                    print 'Ignoring '.$file."<br>\n";
 112                          continue;
 113                      }
 114                  }
 115                  if ($include) {
 116                      if ($this->_checkIgnore($this->_getCVSFileName($entry),
 117                            $directory . '/' . $this->_getCVSFileName($entry), 0)) {
 118      //                    print 'Including '.$file."<br\n";
 119                          continue;
 120                      }
 121                  }
 122                  if ($this->_isCVSFile($entry)) {
 123                      $ret[] = $directory . '/' . $this->_getCVSFileName($entry);
 124                  }
 125              }
 126          }
 127          return $ret;
 128      }
 129      
 130      /**
 131       * Retrieve the filename from an entry
 132       *
 133       * This method assumes that the entry is a file,
 134       * use _isCVSFile() to verify before calling
 135       * @param string a line in a CVS/Entries file
 136       * @return string the filename (no path information)
 137       * @access private
 138       */
 139      function _getCVSFileName($cvsentry)
 140      {
 141          $stuff = explode('/', $cvsentry);
 142          array_shift($stuff);
 143          return array_shift($stuff);
 144      }
 145      
 146      /**
 147       * Retrieve the entries in a CVS/Entries file
 148       * @return array each line of the entries file, output of file()
 149       * @uses function file()
 150       * @param string full path to a CVS/Entries file
 151       * @access private
 152       */
 153      function _getCVSEntries($cvsentryfilename)
 154      {
 155          $cvsfile = @file($cvsentryfilename);
 156          if (is_array($cvsfile)) {
 157              return $cvsfile;
 158          } else {
 159              return false;
 160          }
 161      }
 162      
 163      /**
 164       * Check whether an entry is a file or a directory
 165       * @return boolean
 166       * @param string a line in a CVS/Entries file
 167       * @access private
 168       */
 169      function _isCVSFile($cvsentry)
 170      {
 171          // make sure we ignore entries that have either been removed or added, but not committed yet
 172          return $cvsentry{0} == '/' && !strpos($cvsentry, 'dummy timestamp');
 173      }
 174  }
 175  ?>


Généré le : Sun Feb 25 14:08:00 2007 par Balluche grâce à PHPXref 0.7