Archive_Tar::extractList PHP Method

extractList() public method

If indicated the $p_remove_path can be used in the same way as it is used in extractModify() method.
See also: extractModify()
public extractList ( array $p_filelist, string $p_path = '', string $p_remove_path = '' ) : true
$p_filelist array An array of filenames and directory names, or a single string with names separated by a single blank space.
$p_path string The path of the directory where the files/dir need to by extracted.
$p_remove_path string Part of the memorized path that can be removed if present at the beginning of the file/dir path.
return true on success, false on error.
    function extractList($p_filelist, $p_path = '', $p_remove_path = '')
    {
        $v_result = true;
        $v_list_detail = array();
        if (is_array($p_filelist)) {
            $v_list = $p_filelist;
        } elseif (is_string($p_filelist)) {
            $v_list = explode($this->_separator, $p_filelist);
        } else {
            $this->_error('Invalid string list');
            return false;
        }
        if ($v_result = $this->_openRead()) {
            $v_result = $this->_extractList($p_path, $v_list_detail, "partial", $v_list, $p_remove_path);
            $this->_close();
        }
        return $v_result;
    }

Usage Example

 $tar = new Archive_Tar($path . $filename);
 $sFileName = substr($filename, 0, strrpos($filename, '.'));
 $sClassName = substr($filename, 0, strpos($filename, '-'));
 $sClassName = !empty($sClassName) ? $sClassName : $sFileName;
 $files = $tar->listContent();
 $licenseName = '';
 $listFiles = array();
 foreach ($files as $key => $val) {
     if (strpos(trim($val['filename']), 'plugins/') !== false) {
         $listFiles[] = trim($val['filename']);
     }
     if (strpos(trim($val['filename']), 'license_') !== false) {
         $licenseName = trim($val['filename']);
     }
 }
 $tar->extractList($listFiles, PATH_PLUGINS . 'data');
 $tar->extractList($licenseName, PATH_PLUGINS);
 $pluginRegistry =& PMPluginRegistry::getSingleton();
 $autoPlugins = glob(PATH_PLUGINS . "data/plugins/*.tar");
 $autoPluginsA = array();
 foreach ($autoPlugins as $filePath) {
     $plName = basename($filePath);
     //if (!(in_array($plName, $def))) {
     if (strpos($plName, 'enterprise') === false) {
         $autoPluginsA[]["sFilename"] = $plName;
     }
 }
 $aPlugins = $autoPluginsA;
 foreach ($aPlugins as $key => $aPlugin) {
     $sClassName = substr($aPlugin["sFilename"], 0, strpos($aPlugin["sFilename"], "-"));
     $oTar = new Archive_Tar(PATH_PLUGINS . "data/plugins/" . $aPlugin["sFilename"]);
All Usage Examples Of Archive_Tar::extractList