#!/usr/bin/php
<?php
/*
Copyright 2020 Daniel Marschall, ViaThinkSoft
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This script generates SFV files
// If there is already an SFV file existing, only new files get appended to the existing SFV files.
function _rec($directory) {
die("Invalid directory path $directory\n");
}
$sfv_file = $directory.'/'.basename($directory).'.sfv';
$existing_files = sfv_get_files($sfv_file);
} else {
$existing_files = array();
}
foreach (scandir($directory) as $file) {
if ($file === '.') continue;
if ($file === '..') continue;
if (substr($file, -4) === '.md5') continue;
if (substr($file, -4) === '.sfv') continue;
$fullpath = $directory . '/' . $file;
_rec($fullpath);
} else {
### echo "$fullpath\n";
$dir = pathinfo($fullpath, PATHINFO_DIRNAME
);
}
if (!in_array($file, $existing_files)) {
}
}
}
}
function sfv_get_files($filename) {
$lines = file($filename);
foreach ($lines as $line) {
if ($line == '') continue;
if (substr($line,0,1) == ';') continue;
}
return $out;
}
function swapEndianness($hex) {
}
function crc32_file($filename, $rawOutput = false) {
if (hash('crc32b', 'TEST') == 'b893eaee') {
// hash_file() in PHP 5.2 has the wrong Endianess!
// https://bugs.php.net/bug.php?id=47467
$out = swapEndianness($out);
}
return $out;
}
# ---
if ($argc != 2) {
echo "Syntax: $argv[0] <directory>\n";
}
echo "Directory not found\n";
}
_rec($argv[1]);
echo "Done.\n";