überall wo popen ist, musst du ggf. Anpassungen machen.
Das sind exakt 3 Stellen und 2 davon sind cross-platform designed! Also man muss nur in util lua die Zeile
io.popen(string.format([[dir "%s" /b /ad]], dir))
durch
if utils.env.isWinOS then
io.popen(string.format([[dir "%s" /b /ad]], dir))
else
io.popen(string.format([[ls -1d "%s/*/"]], dir))
end
ersetzen:
Error Files = { }
Finished at 13.01.2021 18:40:02
Aber besser man poliert die anderen 2 popen calls auchnoch etwas auf, wenn gewünscht kann ich auch hier meine Änderungen nennen.
//EDIT: Ich war zu schnell... Also hier meine Änderungen:
diff -Nru eat1963_tpf2_converter_0.old/res/scripts/eat1963_tpf2_converter_0_17.lua eat1963_tpf2_converter_0/res/scripts/eat1963_tpf2_converter_0_17.lua
--- eat1963_tpf2_converter_0.old/res/scripts/eat1963_tpf2_converter_0_17.lua 2020-02-07 10:51:52.000000000 +0100
+++ eat1963_tpf2_converter_0/res/scripts/eat1963_tpf2_converter_0_17.lua 2021-01-13 18:39:12.548144725 +0100
@@ -380,7 +380,12 @@
for i, subFolder in ipairs(subFolders) do
logFn("createFolders | {base, subFolder, subFolders} = ", {base, subFolder, subFolders})
if (not test(base..subFolder.."/")) then
- local f = io.popen(string.format([[mkdir "%s""%s"]], base, subFolder))
+ local f;
+ if utils.env.isWinOS then
+ f = io.popen(string.format([[md "%s%s"]], base, subFolder))
+ else
+ f = io.popen(string.format([[mkdir -p "%s%s"]], base, subFolder))
+ end
if f then
f:close()
end
diff -Nru eat1963_tpf2_converter_0.old/res/scripts/eatglobal/utils.lua eat1963_tpf2_converter_0/res/scripts/eatglobal/utils.lua
--- eat1963_tpf2_converter_0.old/res/scripts/eatglobal/utils.lua 2020-01-03 12:16:26.000000000 +0100
+++ eat1963_tpf2_converter_0/res/scripts/eatglobal/utils.lua 2021-01-13 19:18:57.842609137 +0100
@@ -560,7 +560,7 @@
if utils.env.isWinOS then
cmd = '"del '..quote(fileName)..'" '
else
- cmd = '"rm '..quote("./"..fileName)..'" '
+ cmd = '"rm '..fileName..'" '
end
p = io.popen(cmd)
if p then
@@ -571,11 +571,21 @@
function utils.getSubDirs(dir)
local result = {}
- local f = io.popen(string.format([[dir "%s" /b /ad]], dir))
+ local f = nil
+ if utils.env.isWinOS then
+ f = io.popen(string.format([[dir "%s" /b /ad]], dir))
+ else
+ f = io.popen(string.format([[ls -1d "%s*/"]], dir))
+ end
+
if f then
for s in f:lines() do
if (string.len(s) > 0) then
- result[#result + 1] = string.format([[%s%s/]], dir, s)
+ if utils.env.isWinOS then
+ result[#result + 1] = string.format([[%s%s/]], dir, s)
+ else
+ result[#result + 1] = string.format([[%s%s]], dir, s)
+ end
end
end
f:close()
@@ -587,7 +597,13 @@
function utils.getFiles(dir, filterFn)
filterFn = filterFn or function(fileName) return true end
local result = {}
- local f = io.popen(string.format([[dir "%s" /b /a-d]], dir))
+ local f = nil
+ if utils.env.isWinOS then
+ f = io.popen(string.format([[dir "%s" /b /a-d]], dir))
+ else
+ f = io.popen(string.format([[ls -1p "%s" | grep -v /]], dir))
+ end
+
if f then
for s in f:lines() do
if ((string.len(s) > 0) and filterFn(s))then
Alles anzeigen
Aber der Founded Files array bleibt leer und somit wird nix gemacht. Weiss jemand wie man das weiter debuggen kann?
//EDIT²: neue Tag, neuer Patch
diff -Nru eat1963_tpf2_converter_0.old/res/scripts/eat1963_tpf2_converter_0_17.lua eat1963_tpf2_converter_0/res/scripts/eat1963_tpf2_converter_0_17.lua
--- eat1963_tpf2_converter_0.old/res/scripts/eat1963_tpf2_converter_0_17.lua 2020-02-07 10:51:52.000000000 +0100
+++ eat1963_tpf2_converter_0/res/scripts/eat1963_tpf2_converter_0_17.lua 2021-01-14 10:25:15.024983796 +0100
@@ -380,7 +380,12 @@
for i, subFolder in ipairs(subFolders) do
logFn("createFolders | {base, subFolder, subFolders} = ", {base, subFolder, subFolders})
if (not test(base..subFolder.."/")) then
- local f = io.popen(string.format([[mkdir "%s""%s"]], base, subFolder))
+ local f;
+ if utils.env.isWinOS then
+ f = io.popen(string.format([[md "%s%s"]], base, subFolder))
+ else
+ f = io.popen(string.format([[mkdir -p "%s%s"]], base, subFolder))
+ end
if f then
f:close()
end
diff -Nru eat1963_tpf2_converter_0.old/res/scripts/eatglobal/utils.lua eat1963_tpf2_converter_0/res/scripts/eatglobal/utils.lua
--- eat1963_tpf2_converter_0.old/res/scripts/eatglobal/utils.lua 2020-01-03 12:16:26.000000000 +0100
+++ eat1963_tpf2_converter_0/res/scripts/eatglobal/utils.lua 2021-01-14 10:36:11.835501176 +0100
@@ -560,7 +560,7 @@
if utils.env.isWinOS then
cmd = '"del '..quote(fileName)..'" '
else
- cmd = '"rm '..quote("./"..fileName)..'" '
+ cmd = '"rm '..fileName..'" '
end
p = io.popen(cmd)
if p then
@@ -571,11 +571,21 @@
function utils.getSubDirs(dir)
local result = {}
- local f = io.popen(string.format([[dir "%s" /b /ad]], dir))
+ local f = nil
+ if utils.env.isWinOS then
+ f = io.popen(string.format([[dir "%s" /b /ad]], dir))
+ else
+ f = io.popen(string.format([[find "%s" -maxdepth 1 -type d | sed -n '1!p']], dir))
+ end
+
if f then
for s in f:lines() do
if (string.len(s) > 0) then
- result[#result + 1] = string.format([[%s%s/]], dir, s)
+ if utils.env.isWinOS then
+ result[#result + 1] = string.format("%s%s/", dir, s)
+ else
+ result[#result + 1] = string.format("%s/", s)
+ end
end
end
f:close()
@@ -587,7 +597,13 @@
function utils.getFiles(dir, filterFn)
filterFn = filterFn or function(fileName) return true end
local result = {}
- local f = io.popen(string.format([[dir "%s" /b /a-d]], dir))
+ local f = nil
+ if utils.env.isWinOS then
+ f = io.popen(string.format([[dir "%s" /b /a-d]], dir))
+ else
+ f = io.popen(string.format([[ls -1p "%s" | grep -v /]], dir))
+ end
+
if f then
for s in f:lines() do
if ((string.len(s) > 0) and filterFn(s))then
Alles anzeigen
Ergebnis:
Sieht für mich erstmal gut aus aber es wäre gut wenn jemand mit Zugriff auf Windows und Linux das ganze auf Herz und Nieren testen könnte. Auch bin ich noch nicht ganz zufrieden mit hacks wie "find "%s" -maxdepth 1 -type d | sed -n '1!p'"...