Mercurial > ec-dotfiles
comparison bin/ed2k @ 744:8d3ad5ae1ce4
[ed2k] better? function organization and usage of argv
| author | nanaya <me@nanaya.net> |
|---|---|
| date | Wed, 05 Feb 2025 17:14:38 +0900 |
| parents | bcdf320dabf4 |
| children |
comparison
equal
deleted
inserted
replaced
| 743:2b0112948102 | 744:8d3ad5ae1ce4 |
|---|---|
| 14 fclose($fp); | 14 fclose($fp); |
| 15 | 15 |
| 16 return hash('md4', $hash); | 16 return hash('md4', $hash); |
| 17 } | 17 } |
| 18 | 18 |
| 19 for ($i = 1; $i < $argc; $i++) { | 19 function main(): void |
| 20 $path = $argv[$i]; | 20 { |
| 21 $hash = ed2k_hash($path); | 21 $files = $_SERVER['argv']; |
| 22 $filename = basename($path); | 22 array_shift($files); |
| 23 $filesize = filesize($path); | |
| 24 | 23 |
| 25 echo "ed2k://|file|{$filename}|{$filesize}|{$hash}|"; | 24 foreach ($files as $path) { |
| 26 echo PHP_EOL; | 25 $hash = ed2k_hash($path); |
| 26 $filename = basename($path); | |
| 27 $filesize = filesize($path); | |
| 28 | |
| 29 echo "ed2k://|file|{$filename}|{$filesize}|{$hash}|", PHP_EOL; | |
| 30 } | |
| 27 } | 31 } |
| 32 | |
| 33 main(); |
