Ejemplo n.º 1
0
 public function create($paths, $filename = FALSE)
 {
     $archive = new Archive('tar');
     foreach ($paths as $set) {
         $archive->add($set[0], $set[1]);
     }
     $gzfile = bzcompress($archive->create());
     if ($filename == FALSE) {
         return $gzfile;
     }
     if (substr($filename, -8) !== '.tar.bz2') {
         // Append tar extension
         $filename .= '.tar.bz2';
     }
     // Create the file in binary write mode
     $file = fopen($filename, 'wb');
     // Lock the file
     flock($file, LOCK_EX);
     // Write the tar file
     $return = fwrite($file, $gzfile);
     // Unlock the file
     flock($file, LOCK_UN);
     // Close the file
     fclose($file);
     return (bool) $return;
 }
Ejemplo n.º 2
0
 public function archive($build = FALSE)
 {
     if ($build === 'build') {
         // Load archive
         $archive = new Archive('zip');
         // Download the application/views directory
         $archive->add(APPPATH . 'views/', 'app_views/', TRUE);
         // Download the built archive
         $archive->download('test.zip');
     } else {
         echo html::anchor(Router::$current_uri . '/build', 'Download views');
     }
 }
Ejemplo n.º 3
0
 public static function create($save_path, $files)
 {
     // Since files can be an array or a path...
     if (!is_array($files)) {
         $files = array($files);
     }
     $archive = new Archive();
     // Loop through files...(or the one directory/file)
     foreach ($files as $file) {
         if (file_exists($file)) {
             $archive->add($file);
         }
     }
     // Save the file
     $archive->save($save_path);
     // Status
     return file_exists($save_path);
 }