Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 135... Línea 135...
135
     * @param tgz_extractor_handler $handler Will be called for extracted files
135
     * @param tgz_extractor_handler $handler Will be called for extracted files
136
     * @param file_progress $progress Optional progress reporting
136
     * @param file_progress $progress Optional progress reporting
137
     * @return array Array from archive path => true of processed files
137
     * @return array Array from archive path => true of processed files
138
     * @throws moodle_exception If there is any error processing the archive
138
     * @throws moodle_exception If there is any error processing the archive
139
     */
139
     */
140
    public function extract(tgz_extractor_handler $handler, file_progress $progress = null) {
140
    public function extract(tgz_extractor_handler $handler, ?file_progress $progress = null) {
141
        $this->mode = self::MODE_EXTRACT;
141
        $this->mode = self::MODE_EXTRACT;
142
        $this->extract_or_list($handler, $progress);
142
        $this->extract_or_list($handler, $progress);
143
        $results = $this->results;
143
        $results = $this->results;
144
        unset($this->results);
144
        unset($this->results);
145
        return $results;
145
        return $results;
Línea 150... Línea 150...
150
     *
150
     *
151
     * @param tgz_extractor_handler $handler Optional handler
151
     * @param tgz_extractor_handler $handler Optional handler
152
     * @param file_progress $progress Optional progress reporting
152
     * @param file_progress $progress Optional progress reporting
153
     * @throws moodle_exception If there is any error processing the archive
153
     * @throws moodle_exception If there is any error processing the archive
154
     */
154
     */
155
    protected function extract_or_list(tgz_extractor_handler $handler = null, file_progress $progress = null) {
155
    protected function extract_or_list(?tgz_extractor_handler $handler = null, ?file_progress $progress = null) {
156
        // Open archive.
156
        // Open archive.
157
        if ($this->storedfile) {
157
        if ($this->storedfile) {
158
            $gz = $this->storedfile->get_content_file_handle(stored_file::FILE_HANDLE_GZOPEN);
158
            $gz = $this->storedfile->get_content_file_handle(stored_file::FILE_HANDLE_GZOPEN);
159
            // Estimate number of read-buffers (64KB) in file. Guess that the
159
            // Estimate number of read-buffers (64KB) in file. Guess that the
160
            // uncompressed size is 2x compressed size. Add one just to ensure
160
            // uncompressed size is 2x compressed size. Add one just to ensure
Línea 343... Línea 343...
343
     * Processes one 512-byte block of an existing file.
343
     * Processes one 512-byte block of an existing file.
344
     *
344
     *
345
     * @param string $block Data block
345
     * @param string $block Data block
346
     * @param tgz_extractor_handler $handler Will be called for extracted files
346
     * @param tgz_extractor_handler $handler Will be called for extracted files
347
     */
347
     */
348
    protected function process_file_block($block, tgz_extractor_handler $handler = null) {
348
    protected function process_file_block($block, ?tgz_extractor_handler $handler = null) {
349
        // Write block into buffer.
349
        // Write block into buffer.
350
        $blocksize = tgz_packer::TAR_BLOCK_SIZE;
350
        $blocksize = tgz_packer::TAR_BLOCK_SIZE;
351
        if ($this->currentfileprocessed + tgz_packer::TAR_BLOCK_SIZE > $this->currentfilesize) {
351
        if ($this->currentfileprocessed + tgz_packer::TAR_BLOCK_SIZE > $this->currentfilesize) {
352
            // Partial block at end of file.
352
            // Partial block at end of file.
353
            $blocksize = $this->currentfilesize - $this->currentfileprocessed;
353
            $blocksize = $this->currentfilesize - $this->currentfileprocessed;
Línea 387... Línea 387...
387
     * @param int $mtime File-modified time
387
     * @param int $mtime File-modified time
388
     * @param tgz_extractor_handler $handler Will be called for extracted files
388
     * @param tgz_extractor_handler $handler Will be called for extracted files
389
     * @throws moodle_exception
389
     * @throws moodle_exception
390
     */
390
     */
391
    protected function start_current_file($archivepath, $filesize, $mtime,
391
    protected function start_current_file($archivepath, $filesize, $mtime,
392
            tgz_extractor_handler $handler = null) {
392
            ?tgz_extractor_handler $handler = null) {
393
        global $CFG;
393
        global $CFG;
Línea 394... Línea 394...
394
 
394
 
395
        $this->currentarchivepath = $archivepath;
395
        $this->currentarchivepath = $archivepath;
396
        $this->currentmtime = $mtime;
396
        $this->currentmtime = $mtime;