Archive_Tar::add PHP Method

add() public method

The method return false and a PEAR error text. The files and directories listed are only added at the end of the archive, even if a file with the same name is already archived. See also createModify() method for more details.
See also: createModify()
public add ( array $p_filelist ) : true
$p_filelist array An array of filenames and directory names, or a single string with names separated by a single blank space.
return true on success, false on error.
    function add($p_filelist)
    {
        return $this->addModify($p_filelist, '', '');
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Method to create an archive file
  *
  * @param  string|array $files
  * @return void
  */
 public function addFiles($files)
 {
     if (!is_array($files)) {
         $files = array($files);
     }
     foreach ($files as $file) {
         // If file is a directory, loop through and add the files.
         if (file_exists($file) && is_dir($file)) {
             $realpath = realpath($file);
             $dir = new Dir($file, true, true);
             $dirFiles = $dir->getFiles();
             foreach ($dirFiles as $fle) {
                 if (file_exists($fle) && !is_dir($fle)) {
                     $fle = $file . DIRECTORY_SEPARATOR . str_replace($realpath . DIRECTORY_SEPARATOR, '', $fle);
                     $this->archive->add($fle);
                 }
             }
             // Else, just add the file.
         } else {
             if (file_exists($file)) {
                 $this->archive->add($file);
             }
         }
     }
 }
All Usage Examples Of Archive_Tar::add