Browse Source

fonction inutilisées mais implémentées quand même : retirer(), emballer() un tar/tgz

pull/4416/head
JamesRezo 10 months ago
parent
commit
05664c06fc
  1. 2
      phpstan-baseline.neon
  2. 4
      src/AbstractArchiver.php
  3. 23
      src/TarArchive.php
  4. 8
      src/ZipArchive.php
  5. 11
      tests/SpipArchiverTest.php

2
phpstan-baseline.neon

@ -2,7 +2,7 @@ parameters:
ignoreErrors:
-
message: "#^Function include_spip not found\\.$#"
count: 9
count: 8
path: inc/archives.php
-

4
src/AbstractArchiver.php

@ -229,6 +229,10 @@ abstract class AbstractArchiver implements ArchiverInterface
$max_n = min($n, $max_n);
}
if (empty($paths)) {
return '';
}
$total = $paths[0][''];
$i = 0;
while (

23
src/TarArchive.php

@ -35,6 +35,10 @@ class TarArchive implements ArchiveInterface
public function list(): array {
$files = [];
if ('' === $this->tar->getPathname()) {
return $files;
}
$root_dir = dirname($this->tar->getPathname());
$source = new NoDotFilterIterator(
new \RecursiveIteratorIterator(
@ -55,7 +59,18 @@ class TarArchive implements ArchiveInterface
* {@inheritDoc}
*/
public function compress(string $source = '', array $files = []): bool {
return false;
foreach ($files as $file) {
$this->tar->addFile(
$file,
(string) str_replace(
realpath($source) . '/',
'',
(string) realpath($file)
)
);
}
return true;
}
/**
@ -73,7 +88,11 @@ class TarArchive implements ArchiveInterface
* {@inheritDoc}
*/
public function remove(array $files = []): bool {
return false;
foreach ($files as $file) {
unset($this->tar[$file]);
}
return true;
}
/**

8
src/ZipArchive.php

@ -74,7 +74,13 @@ class ZipArchive implements ArchiveInterface
* {@inheritDoc}
*/
public function remove(array $files = []): bool {
return false;
$ok = true;
foreach ($files as $file) {
$ok = $ok && $this->zip->deleteName($file);
}
return $ok;
}
/**

11
tests/SpipArchiverTest.php

@ -98,6 +98,17 @@ class SpipArchiverTest extends TestCase
__DIR__ . '/../var/tmp/tar/test.tar',
'',
],
'empty-tar' => [
0,
[
'proprietes' => [
'racine' => '',
],
'fichiers' => [],
],
__DIR__ . '/../var/tmp/tar/empty.tar',
'tar',
],
'tgz' => [
0,
[

Loading…
Cancel
Save