| Línea 53... |
Línea 53... |
| 53 |
* @param file_progress $progress Progress indicator callback or null if not required
|
53 |
* @param file_progress $progress Progress indicator callback or null if not required
|
| 54 |
* @return stored_file|bool false if error stored_file instance if ok
|
54 |
* @return stored_file|bool false if error stored_file instance if ok
|
| 55 |
*/
|
55 |
*/
|
| 56 |
public function archive_to_storage(array $files, $contextid,
|
56 |
public function archive_to_storage(array $files, $contextid,
|
| 57 |
$component, $filearea, $itemid, $filepath, $filename,
|
57 |
$component, $filearea, $itemid, $filepath, $filename,
|
| 58 |
$userid = NULL, $ignoreinvalidfiles=true, file_progress $progress = null) {
|
58 |
$userid = NULL, $ignoreinvalidfiles=true, ?file_progress $progress = null) {
|
| 59 |
global $CFG;
|
59 |
global $CFG;
|
| Línea 60... |
Línea 60... |
| 60 |
|
60 |
|
| Línea 61... |
Línea 61... |
| 61 |
$fs = get_file_storage();
|
61 |
$fs = get_file_storage();
|
| Línea 94... |
Línea 94... |
| 94 |
* @param bool $ignoreinvalidfiles true means ignore missing or invalid files, false means abort on any error
|
94 |
* @param bool $ignoreinvalidfiles true means ignore missing or invalid files, false means abort on any error
|
| 95 |
* @param file_progress $progress Progress indicator callback or null if not required
|
95 |
* @param file_progress $progress Progress indicator callback or null if not required
|
| 96 |
* @return bool true if file created, false if not
|
96 |
* @return bool true if file created, false if not
|
| 97 |
*/
|
97 |
*/
|
| 98 |
public function archive_to_pathname(array $files, $archivefile,
|
98 |
public function archive_to_pathname(array $files, $archivefile,
|
| 99 |
$ignoreinvalidfiles=true, file_progress $progress = null) {
|
99 |
$ignoreinvalidfiles=true, ?file_progress $progress = null) {
|
| 100 |
$ziparch = new zip_archive();
|
100 |
$ziparch = new zip_archive();
|
| 101 |
if (!$ziparch->open($archivefile, file_archive::OVERWRITE)) {
|
101 |
if (!$ziparch->open($archivefile, file_archive::OVERWRITE)) {
|
| 102 |
return false;
|
102 |
return false;
|
| 103 |
}
|
103 |
}
|
| Línea 171... |
Línea 171... |
| 171 |
* @param string $archivepath file path to archive
|
171 |
* @param string $archivepath file path to archive
|
| 172 |
* @param stored_file $file stored_file object
|
172 |
* @param stored_file $file stored_file object
|
| 173 |
* @param file_progress $progress Progress indicator callback or null if not required
|
173 |
* @param file_progress $progress Progress indicator callback or null if not required
|
| 174 |
* @return bool success
|
174 |
* @return bool success
|
| 175 |
*/
|
175 |
*/
|
| 176 |
private function archive_stored($ziparch, $archivepath, $file, file_progress $progress = null) {
|
176 |
private function archive_stored($ziparch, $archivepath, $file, ?file_progress $progress = null) {
|
| 177 |
$result = $file->archive_file($ziparch, $archivepath);
|
177 |
$result = $file->archive_file($ziparch, $archivepath);
|
| 178 |
if (!$result) {
|
178 |
if (!$result) {
|
| 179 |
return false;
|
179 |
return false;
|
| 180 |
}
|
180 |
}
|
| Línea 214... |
Línea 214... |
| 214 |
* @param string $file path name of the file
|
214 |
* @param string $file path name of the file
|
| 215 |
* @param file_progress $progress Progress indicator callback or null if not required
|
215 |
* @param file_progress $progress Progress indicator callback or null if not required
|
| 216 |
* @return bool success
|
216 |
* @return bool success
|
| 217 |
*/
|
217 |
*/
|
| 218 |
private function archive_pathname($ziparch, $archivepath, $file,
|
218 |
private function archive_pathname($ziparch, $archivepath, $file,
|
| 219 |
file_progress $progress = null) {
|
219 |
?file_progress $progress = null) {
|
| 220 |
// Record progress each time this function is called.
|
220 |
// Record progress each time this function is called.
|
| 221 |
if ($progress) {
|
221 |
if ($progress) {
|
| 222 |
$progress->progress();
|
222 |
$progress->progress();
|
| 223 |
}
|
223 |
}
|
| Línea 261... |
Línea 261... |
| 261 |
* @param bool $returnbool Whether to return a basic true/false indicating error state, or full per-file error
|
261 |
* @param bool $returnbool Whether to return a basic true/false indicating error state, or full per-file error
|
| 262 |
* details.
|
262 |
* details.
|
| 263 |
* @return bool|array list of processed files; false if error
|
263 |
* @return bool|array list of processed files; false if error
|
| 264 |
*/
|
264 |
*/
|
| 265 |
public function extract_to_pathname($archivefile, $pathname,
|
265 |
public function extract_to_pathname($archivefile, $pathname,
|
| 266 |
array $onlyfiles = null, file_progress $progress = null, $returnbool = false) {
|
266 |
?array $onlyfiles = null, ?file_progress $progress = null, $returnbool = false) {
|
| 267 |
global $CFG;
|
267 |
global $CFG;
|
| Línea 268... |
Línea 268... |
| 268 |
|
268 |
|
| 269 |
if (!is_string($archivefile)) {
|
269 |
if (!is_string($archivefile)) {
|
| 270 |
return $archivefile->extract_to_pathname($this, $pathname, $progress);
|
270 |
return $archivefile->extract_to_pathname($this, $pathname, $progress);
|
| Línea 422... |
Línea 422... |
| 422 |
* @param file_progress $progress Progress indicator callback or null if not required
|
422 |
* @param file_progress $progress Progress indicator callback or null if not required
|
| 423 |
* @return array|bool list of processed files; false if error
|
423 |
* @return array|bool list of processed files; false if error
|
| 424 |
*/
|
424 |
*/
|
| 425 |
public function extract_to_storage($archivefile, $contextid,
|
425 |
public function extract_to_storage($archivefile, $contextid,
|
| 426 |
$component, $filearea, $itemid, $pathbase, $userid = NULL,
|
426 |
$component, $filearea, $itemid, $pathbase, $userid = NULL,
|
| 427 |
file_progress $progress = null) {
|
427 |
?file_progress $progress = null) {
|
| 428 |
global $CFG;
|
428 |
global $CFG;
|
| Línea 429... |
Línea 429... |
| 429 |
|
429 |
|
| 430 |
if (!is_string($archivefile)) {
|
430 |
if (!is_string($archivefile)) {
|
| 431 |
return $archivefile->extract_to_storage($this, $contextid, $component,
|
431 |
return $archivefile->extract_to_storage($this, $contextid, $component,
|