long filenames

master
Theunis J. Botha 2021-06-21 11:43:10 +02:00
parent 9ec0a610bb
commit 89a39b14dc
4 changed files with 46 additions and 74 deletions

View File

@ -1,38 +1,9 @@
#!/usr/bin/php
<?php
if (isset($argc)) {
for ($i = 0; $i < $argc; $i++) {
echo "Argument #" . $i . " - " . $argv[$i] . "\n";
}
}
else {
echo "argc and argv disabled\n";
}
include "utils.php";
if ($argv[1] == 'all') {
$files = scandir('src/r3/', SCANDIR_SORT_DESCENDING);
$systemFiles = scandir('src/r3/r3-system', SCANDIR_SORT_DESCENDING);
$newFiles = [];
for ($i = 0; $i < sizeof($files); $i++) {
if (preg_match('/\.js$/', $files[$i])) {
array_push($newFiles, 'src/r3/' . $files[$i]);
}
}
for ($i = 0; $i < sizeof($systemFiles); $i++) {
if (preg_match('/\.js$/', $systemFiles[$i])) {
array_push($newFiles, 'src/r3/r3-system/' . $systemFiles[$i]);
}
}
$files = $newFiles;
} else {
$files = [$argv[1]];
}
global $files;
foreach ($files as $file) {

View File

@ -1,31 +1,9 @@
#!/usr/bin/php
<?php
if (isset($argc)) {
for ($i = 0; $i < $argc; $i++) {
echo "Argument #" . $i . " - " . $argv[$i] . "\n";
}
}
else {
echo "argc and argv disabled\n";
}
include "utils.php";
if ($argv[1] == 'all') {
$files = scandir('src/r3', SCANDIR_SORT_DESCENDING);
$newFiles = [];
for ($i = 0; $i < sizeof($files); $i++) {
if (preg_match('/\.js$/', $files[$i])) {
array_push($newFiles, 'src/r3/' . $files[$i]);
}
}
$files = $newFiles;
} else {
$files = [$argv[1]];
}
global $files;
foreach ($files as $file) {

View File

@ -1,14 +1,7 @@
#!/usr/bin/php
<?php
if (isset($argc)) {
for ($i = 0; $i < $argc; $i++) {
echo "Argument #" . $i . " - " . $argv[$i] . "\n";
}
}
else {
echo "argc and argv disabled\n";
}
include "utils.php";
$tokens = [
'OPTIONS_START' => 'OPTIONS_END',
@ -28,8 +21,6 @@ $tokens = [
'CUSTOM_[A..Z_]+_METHOD_START' => 'CUSTOM_[A..Z_]+_METHOD_END'
];
$files = [$argv[2]];
function getIndex($needle, $haystack) {
$index = 0;
@ -44,23 +35,18 @@ function getIndex($needle, $haystack) {
return false;
}
global $files;
foreach ($files as $file) {
if ($argv[1] == 'save') {
if ($argv[2] == 'save') {
echo "saving file " . $file . "\n";
$saved = [];
$startSaving = false;
$fn = null;
// try {
$fn = fopen($file, "r");
// } catch (Exception $e) {
// $file = "r3-system/" . $file;
// $fn = fopen($file, "r");
// }
while (!feof($fn)) {
@ -93,9 +79,10 @@ foreach ($files as $file) {
fclose($fn);
file_put_contents($file . '.saved', $saved);
echo "saved file " . $file . ".saved\n";
} else if ($argv[1] == 'restore') {
} else if ($argv[2] == 'restore') {
$saveFile = $file . '.saved';

36
utils.php Normal file
View File

@ -0,0 +1,36 @@
<?php
if (isset($argc)) {
for ($i = 0; $i < $argc; $i++) {
echo "Argument #" . $i . " - " . $argv[$i] . "\n";
}
}
else {
echo "argc and argv disabled\n";
}
$files = [];
if ($argv[1] == 'all') {
$files = scandir('src/r3/', SCANDIR_SORT_DESCENDING);
$systemFiles = scandir('src/r3/r3-system', SCANDIR_SORT_DESCENDING);
$newFiles = [];
for ($i = 0; $i < sizeof($files); $i++) {
if (preg_match('/\.js$/', $files[$i])) {
array_push($newFiles, 'src/r3/' . $files[$i]);
}
}
for ($i = 0; $i < sizeof($systemFiles); $i++) {
if (preg_match('/\.js$/', $systemFiles[$i])) {
array_push($newFiles, 'src/r3/r3-system/' . $systemFiles[$i]);
}
}
$files = $newFiles;
} else {
$files = [$argv[1]];
}