Merge branch 'MDL-29276' of git://github.com/mouneyrac/moodle
[moodle.git] / lib / filestorage / file_packer.php
blob99aa281fab05b4baea62d7923a924cb5fa909fde
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 /**
20 * Abstraction of general file packer.
22 * @package core
23 * @subpackage filestorage
24 * @copyright 2008 Petr Skoda (http://skodak.org)
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 defined('MOODLE_INTERNAL') || die();
30 /**
31 * Abstract class for archiving of files.
33 * @package core
34 * @subpackage filestorage
35 * @copyright 2008 Petr Skoda (http://skodak.org)
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 abstract class file_packer {
40 /**
41 * Archive files and store the result in file storage
42 * @param array $files array with zip paths as keys (archivepath=>ospathname or archivepath=>stored_file)
43 * @param int $contextid
44 * @param string $component
45 * @param string $filearea
46 * @param int $itemid
47 * @param string $filepath
48 * @param string $filename
49 * @return mixed false if error stored file instance if ok
51 public abstract function archive_to_storage($files, $contextid, $component, $filearea, $itemid, $filepath, $filename, $userid = NULL);
53 /**
54 * Archive files and store the result in os file
55 * @param array $files array with zip paths as keys (archivepath=>ospathname or archivepath=>stored_file)
56 * @param string $archivefile path to target zip file
57 * @return bool success
59 public abstract function archive_to_pathname($files, $archivefile);
61 /**
62 * Extract file to given file path (real OS filesystem), existing files are overwrited
63 * @param mixed $archivefile full pathname of zip file or stored_file instance
64 * @param string $pathname target directory
65 * @return mixed list of processed files; false if error
67 public abstract function extract_to_pathname($archivefile, $pathname);
69 /**
70 * Extract file to given file path (real OS filesystem), existing files are overwrited
71 * @param mixed $archivefile full pathname of zip file or stored_file instance
72 * @param int $contextid
73 * @param string $component
74 * @param string $filearea
75 * @param int $itemid
76 * @param string $filepath
77 * @return mixed list of processed files; false if error
79 public abstract function extract_to_storage($archivefile, $contextid, $component, $filearea, $itemid, $pathbase, $userid = NULL);
81 /**
82 * Returns array of info about all files in archive
83 * @return array of file infos
85 public abstract function list_files($archivefile);