-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.php
More file actions
30 lines (23 loc) · 695 Bytes
/
example.php
File metadata and controls
30 lines (23 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
declare(strict_types=1);
use JakubBoucek\Tar\FileReader;
require __DIR__ . '/vendor/autoload.php';
if (PHP_SAPI !== 'cli') {
http_response_code(400);
echo 'ERROR: Tool is callable only from command-line' . PHP_EOL;
die(1);
}
// Parse & validate command arguments
if ($argc < 2) {
throw new RuntimeException(sprintf('Usage: %s <file>', basename(__FILE__)));
}
$archiveFile = $argv[1];
foreach (new FileReader($archiveFile) as $file) {
echo sprintf(
"%20s: announced %6s bytes, really %6s bytes, hash: %s\n",
$file->getName(),
$file->getSize(),
strlen((string)$file->getContent()),
md5((string)$file->getContent())
);
}