コード例 #1
0
ファイル: ffarchive_test.php プロジェクト: mbcraft/frozen
 function testCompressUncompress()
 {
     $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/test.ffa");
     $f->delete();
     FFArchive::compress($f, new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/data/"));
     $ext_dir = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/");
     $ext_dir->touch();
     $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/compress/test.ffa");
     $this->assertTrue($f->exists(), "Il file da decomprimere non esiste!!");
     FFArchive::extract($f, $ext_dir);
     $f1 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/cartella.png");
     $this->assertTrue($f1->exists(), "Il file cartella.png non e' stato estratto!!");
     $this->assertEqual($f1->getSize(), 441, "La dimensione di cartella.png non corrisponde!!");
     $f2 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/file1.txt");
     $this->assertTrue($f2->exists(), "Il file file1.txt non e' stato estratto!!");
     $f3 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/file2.dat");
     $this->assertTrue($f3->exists(), "Il file file2.dat non e' stato estratto!!");
     $d1 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/empty_folder");
     $this->assertTrue($d1->exists(), "La cartella vuota non e' stata estratta!!");
     $d2 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/folder");
     $this->assertTrue($d2->exists(), "La cartella folder non e' stata estratta!!");
     $f4 = new File("/" . FRAMEWORK_CORE_PATH . "tests/utils/extract/folder/sub/yep.txt");
     $this->assertTrue($f4->exists(), "Il file yep.txt non e' stato estratto!!");
     $this->assertEqual($f4->getSize(), 10, "La dimensione di yep.txt non corrisponde!!");
     $this->assertTrue($ext_dir->delete(true), "La directory coi file estratti non e' stata elimintata!!");
     $this->assertFalse($f1->exists(), "Il file cartella.png esiste ancora!!");
 }
コード例 #2
0
 static function extract_from_archive($filename)
 {
     $modules_archive_dir = new Dir(self::MODULES_ARCHIVE_DIR);
     $modules_archive_dir->touch();
     $module_archive = $modules_archive_dir->newFile($filename);
     $properties = FFArchive::getArchiveProperties($module_archive);
     $module_dir = new Dir(ModuleUtils::get_modules_path() . "/" . $properties["category_name"] . "/" . $properties["module_name"]);
     return FFArchive::extract($module_archive, $module_dir);
 }
コード例 #3
0
 function execute()
 {
     $archive_file_path = $this->archive_file_path;
     $to_folder = $this->to_folder;
     if (self::$dummy_mode) {
         echo "Extracting : " . $archive_file_path . " to " . $to_folder . "<br />";
         return;
     }
     $real_archive_file_path = new File($this->module_dir . DS . $archive_file_path);
     $real_folder = new Dir(self::$root_dir . DS . $to_folder);
     FFArchive::extract($real_archive_file_path, $real_folder);
 }
コード例 #4
0
ファイル: Backup.class.php プロジェクト: mbcraft/frozen
 public static function restore_dir($dir)
 {
     $backup_dir = new Dir(self::$current_backup_dir);
     if (!$backup_dir->exists()) {
         return false;
     }
     if ($dir instanceof Dir) {
         $d = $dir;
     } else {
         $d = new Dir($dir);
     }
     $file = new File(self::getDirBackupFile($d));
     FFArchive::extract($file, $dir);
     return $file->getPath();
 }
コード例 #5
0
ファイル: extract_archive.php プロジェクト: mbcraft/frozen
<?php

/* This software is released under the BSD license. Full text at project root -> license.txt */
require_once "../init.php";
if (isset($_POST["extract"])) {
    FFArchive::extract(new File($_POST["target_file"]), new Dir($_POST["target_dir"]));
    $result = "Archive extracted.";
} else {
    $result = null;
}
?>
<html>
<head>
    <title>Extract 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/extract_archive.php">
    <input type="hidden" name="extract" value="extract" />
    Archive file : <input type="text" name="target_file" value="/package.ffa" /><br />
    Target dir : <input type="text" name="target_dir" value="/" /><br />
    <br />
    <button type="submit">
        <div>
            Extract
        </div>
    </button>