public static function backup_dir($dir) { self::checkBackupDir(); if ($dir instanceof Dir) { $d = $dir; } else { $d = new Dir($dir); } $file = new File(self::getDirBackupFile($d)); FFArchive::compress($file, $d, array("type" => "dir_backup", "description" => "Backup of dir " . $d->getPath())); return $file->getPath(); }
function testArchiveProperties() { $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/test.ffa"); $f->delete(); $this->assertFalse($f->exists()); $input_properties["description"] = "Archivio immagini rotator"; $input_properties["image1"] = "colori.jpg"; $input_properties["image2"] = "other"; FFArchive::compress($f, new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/data/"), $input_properties); $this->assertTrue($f->exists()); $output_properties = FFArchive::getArchiveProperties($f); $this->assertEqual($output_properties["description"], "Archivio immagini rotator", "La descrizione non e' stata letta correttamente dall'archivio!!"); $this->assertEqual($output_properties["image1"], "colori.jpg", "La proprieta' image1 non e' stata letta correttamente dall'archivio!!"); $this->assertEqual($output_properties["image2"], "other", "La proprieta' image2 non e' stata letta correttamente dall'archivio!!"); $f->delete(true); }
static function save_as_archive($category_name, $module_name) { if (!AvailableModules::is_module_available($category_name, $module_name)) { throw new IllegalStateException("Il modulo " . $category_name . "/" . $module_name . "non risulta disponibile!!"); } $d = new Dir(self::MODULES_ARCHIVE_DIR); $d->touch(); $spec = AvailableModules::get_available_module_definition($category_name, $module_name); $category_name = $spec->get_category_name(); $module_name = $spec->get_module_name(); $version = $spec->get_current_version(); $v = $version["major_version"] . "_" . $version["minor_version"] . "_" . $version["revision"]; $archive_dir = new Dir(self::MODULES_ARCHIVE_DIR); $archive_dir->touch(); $source_dir = new Dir(ModuleUtils::get_modules_path() . "/" . $category_name . "/" . $module_name . "/"); $target_file = $archive_dir->newFile($category_name . "__" . $module_name . "-" . $v . ".ffa"); $properties = array(); $properties["category_name"] = $category_name; $properties["module_name"] = $module_name; $properties["major_version"] = $version["major_version"]; $properties["minor_version"] = $version["minor_version"]; $properties["revision"] = $version["revision"]; return FFArchive::compress($target_file, $source_dir, $properties); }
<?php /* This software is released under the BSD license. Full text at project root -> license.txt */ require_once "../init.php"; if (isset($_POST["compress"])) { FFArchive::compress(new File($_POST["target_file"]), new Dir($_POST["root_dir"]), $_POST["description"], $_POST["properties"]); $result = "Archive created."; } else { $result = null; } ?> <html> <head> <title>Create a Frozen Framework Archive (FFA)</title> </head> <body> <?php if ($result !== null) { echo "<h1>" . $result . "</h1>"; } ?> <form name="create_archive" method="post" action="/framework/utilities/create_archive.php"> <input type="hidden" name="compress" value="compress" /> Description : <input type="text" name="description" value="" size="40"/><br /> Properties : <br /> <textarea name="properties" rows="7" cols="30"></textarea><br /> Root dir : <input type="text" name="root_dir" value="/" /><br /> Target file : <input type="text" name="target_file" value="/package.ffa" /><br /> <br /> <button type="submit"> <div>
require_once "io/FileSystemUtils.class.php"; require_once "io/Dir.class.php"; require_once "io/File.class.php"; require_once "io/FileReader.class.php"; require_once "io/FileWriter.class.php"; require_once "utils/FFArchive.class.php"; ?> <html> <head> <title>Frostlab gate framework updater</title> </head> <body> <?php if (isset($_POST["do"])) { echo "Archiving ..."; FFArchive::compress(new File("/framework/utilities/framework.ffa"), new Dir("/framework/core")); } else { ?> <form name="form__framework_updater" action="/framework/utilities/framework_update2.php" method="POST"> <input type="hidden" name="do" value="do" /> <br /> <button type="submit"> <div> Aggiorna framework </div> </button> </form> <?php } ?> </body>