add fwkren as a replacement for powershell exec

main
Dominik Madarász 2023-08-14 19:05:37 +02:00
parent 8b6f07e5c5
commit e4b6b8ba1f
3 changed files with 34 additions and 2 deletions

View File

@ -472,7 +472,8 @@ if "%1"=="fwk" (
set "filename=%%~nxf"
if /i not "!filename:~0,4!"=="3rd_" (
echo Processing: %%f
powershell -command "(Get-Content '%%f') -creplace 'v4k', 'fwk' -creplace 'V4K', 'FWK' | Set-Content '%%f'"
rem powershell -command "(Get-Content '%%f') -creplace 'v4k', 'fwk' -creplace 'V4K', 'FWK' | Set-Content '%%f'"
tools\fwkren.exe %%f from
) else (
echo Skipping %%f
)
@ -495,7 +496,8 @@ if "%1"=="back" (
set "filename=%%~nxf"
if /i not "!filename:~0,4!"=="3rd_" (
echo Processing: %%f
powershell -command "(Get-Content '%%f') -creplace 'fwk', 'v4k' -creplace 'FWK', 'V4K' | Set-Content '%%f'"
rem powershell -command "(Get-Content '%%f') -creplace 'fwk', 'v4k' -creplace 'FWK', 'V4K' | Set-Content '%%f'"
tools\fwkren.exe %%f to
) else (
echo Skipping %%f
)

30
tools/fwkren.c 100644
View File

@ -0,0 +1,30 @@
#include "v4k.h"
int main(int argc, char **argv) {
if (argc != 3) {
fprintf(stderr, "usage: %s [file] [mode]\n", argv[0]);
fprintf(stderr, "file: %s\n", "source file to process");
fprintf(stderr, "mode: %s\n", "to|from");
return 1;
}
char *buf = file_read(argv[1]);
if (!buf) {
fprintf(stderr, "error: %s\n", "file does not exist!");
return 2;
}
char mode = !strcmp(argv[2], "from");
if (!mode) {
buf = strswap(buf, "v4k", "fwk");
buf = strswap(buf, "V4K", "FWK");
} else {
buf = strswap(buf, "fwk", "v4k");
buf = strswap(buf, "FWK", "V4K");
}
file_write(argv[1], buf, strlen(buf));
return 0;
}

BIN
tools/fwkren.exe 100644

Binary file not shown.