[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/file/unpacker/ -> tarbz2unpacker.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/file/unpacker/baseunpacker.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
   5  
   6      /**
   7       * \ingroup File_Unpacker
   8       *
   9       * Unpacks .tar.gz files.
  10       *
  11       * It users the binaries "tar" and "gzip" to unpack the files. The location of these binaries
  12       * is obtained from the config parameter "path_to_tar" (or /bin/tar if it does not exist) and
  13       * "path_to_gzip" (or /bin/gzip if it does not exist)
  14       *
  15       */
  16      class TarBz2Unpacker extends BaseUnpacker 
  17      {
  18  
  19      	function TarBz2Unpacker()
  20          {
  21              $this->BaseUnpacker();
  22          }
  23  
  24          function unpack( $file, $destFolder )
  25          {
  26              // get the paths where tar and gz are
  27              $config =& Config::getConfig();
  28              $tarPath = $config->getValue( "path_to_tar" );
  29              if( $tarPath == "" )
  30                  $tarPath = DEFAULT_TAR_PATH;
  31  
  32              $bzip2Path = $config->getValue( "path_to_bz2" );
  33              if( $bzip2Path == "" )
  34                  $bzip2Path = DEFAULT_BZIP2_PATH;
  35  
  36              // and now build the command
  37              //$file = escapeshellarg($file);
  38              //$destFolder = escapeshellarg($destFolder);
  39  
  40              //
  41              // :DANGER:
  42              // what if the user voluntarily sets the path of gzip and tar
  43              // to something else? we are doing no checks here to make sure that
  44              // the user is giving us a valid commnand so... how could we make
  45              // sure that it'll work?
  46              //
  47              $cmd = "$bzip2Path -dc $file | $tarPath xv -C $destFolder";
  48  
  49              $result = exec( $cmd, $output, $retval );
  50  
  51              //
  52              // :KLUDGE:
  53              // apparently, we should get something in $retval but there's nothing
  54              // to the only way I've found to check if the command finished
  55              // successfully was checking if the $output array is full or empty
  56              //
  57  
  58              return ($retval==0);
  59          }
  60      }
  61  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics