Пример #1
0
 /**
  * 
  * 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
 /**
  * 
  * Save the provided properties to a file. Supports sections inside the properties data.
  * 
  * @param \Mbcraft\Piol\File|string $file the file instance or string path pointing to the properties file.
  * @param mixed $properties properties data as array or nested arrays if contained in sections.
  * @param boolean $process_sections true if sections must be processed inside properties data, false otherwise
  * 
  * @api
  */
 public static function saveToFile($file, $properties, $process_sections)
 {
     $prop_string = self::saveToString($properties, $process_sections);
     $real_file = File::asFile($file);
     if (!$real_file->exists()) {
         $real_file->touch();
     }
     $real_file->setContent($prop_string);
 }
Пример #3
0
 function testAsFile()
 {
     $f_txt = "/test/test_dir/content_dir/test_file.txt";
     $f = File::asFile($f_txt);
     $this->assertTrue($f instanceof File, "L'oggetto ritornato non è un file!!");
 }