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


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