예제 #1
0
파일: ZipUtils.php 프로젝트: mbcraft/piol
 /**
  * 
  * Creates a zip archive with the content of the specified folder and saves it to the specified file name.
  * 
  * @param \Mbcraft\Piol\File|string $save_file The \Piol\File instance or the string to use as save path for the archive.
  * @param \Mbcraft\Piol\Dir|string $folder_to_zip The \Piol\Dir or the string path pointing to a folder with the elements to archive.
  * @param string $local_dir The directory to use to contain the files inside the archive, defaults to archive root ('/').
  *
  * @throws IOException if an input/output error occurs.
  * 
  * @api
  */
 public static function createArchive($save_file, $folder_to_zip, $local_dir = "/")
 {
     $real_save_file = File::asFile($save_file);
     $dir_to_zip = Dir::asDir($folder_to_zip);
     $zip_archive = new \ZipArchive();
     $zip_archive->open($real_save_file->getFullPath(), \ZipArchive::CREATE);
     ZipUtils::recursiveZipFolder($zip_archive, $dir_to_zip, $local_dir);
     $zip_archive->close();
 }
예제 #2
0
 /**
  * 
  * Construct a FlatDirCache instance, using the specified parameter as folder for data.
  * 
  * @param \Mbcraft\Piol\Dir|string $cache_dir the cache directory or string path for the cache data.
  * 
  * @api
  */
 public function __construct($cache_dir)
 {
     $this->root_dir = Dir::asDir($cache_dir);
 }
예제 #3
0
파일: DirTest.php 프로젝트: mbcraft/piol
 function testAsDir()
 {
     $d = new Dir("/test/more_dir_tests/");
     $this->assertTrue(Dir::asDir($d) instanceof Dir, "L'istanza ritornata non è una Dir.'");
     $this->assertEquals("/test/more_dir_tests/", Dir::asDir($d)->getPath(), "Il percorso ritornato non corrisponde!!");
     $this->assertTrue(Dir::asDir("/test/more_dir_tests/") instanceof Dir, "L'istanza ritornata non è una Dir.'");
     $this->assertEquals("/test/more_dir_tests/", Dir::asDir("/test/more_dir_tests/")->getPath(), "Il percorso ritornato non corrisponde!!");
 }