From 854c6e66cbca8863efbd1d5863bc8ac56dc9c21c Mon Sep 17 00:00:00 2001 From: Yukimasa Morimi Date: Sun, 24 Mar 2024 22:11:41 +0900 Subject: [PATCH] tools/mkmap-*.lua: avoid mkdir error --- tools/mkmap-ai0-ja.lua | 12 ++++++++++-- tools/mkmap-ai0-ko.lua | 12 ++++++++++-- tools/mkmap-ai0-sc.lua | 12 ++++++++++-- tools/mkmap-ai0-tc.lua | 12 ++++++++++-- tools/mkmap-ja.lua | 12 ++++++++++-- tools/mkmap-ko.lua | 12 ++++++++++-- tools/mkmap-sc.lua | 12 ++++++++++-- tools/mkmap-tc.lua | 12 ++++++++++-- 8 files changed, 80 insertions(+), 16 deletions(-) diff --git a/tools/mkmap-ai0-ja.lua b/tools/mkmap-ai0-ja.lua index d45912f..279c5c5 100755 --- a/tools/mkmap-ai0-ja.lua +++ b/tools/mkmap-ai0-ja.lua @@ -227,6 +227,15 @@ local function make_one_line(o, fd, s) end end end +local function mkdir(dirname) + if os.type == "windows" then + dirname = string.gsub(dirname, '/', '\\') + return os.execute('IF NOT EXIST ' .. dirname .. ' MKDIR ' .. dirname) + else + return os.execute('mkdir -p ' .. dirname) + end +end + for fd, v1 in pairs(foundry) do -- separate でないときは mln などのデータベースを省略してあるので ml などからコピー if not foundry[fd].separate then @@ -242,8 +251,7 @@ for fd, v1 in pairs(foundry) do for _,s in pairs(v1[1]) do local dirname = fd print('jaEmbed: ' .. dirname) - -- Linux しか想定していない - os.execute('mkdir ' .. dirname .. ' &>/dev/null') + mkdir(dirname) for mnx, mcont in pairs(maps) do if not string.match(mnx, '-04') or not foundry[fd].noncid or foundry[fd].separate then local mapbase = gsub(mnx, '@', dirname) diff --git a/tools/mkmap-ai0-ko.lua b/tools/mkmap-ai0-ko.lua index cb8e642..6eda376 100755 --- a/tools/mkmap-ai0-ko.lua +++ b/tools/mkmap-ai0-ko.lua @@ -134,12 +134,20 @@ local function make_one_line(o, fd, s) end end end +local function mkdir(dirname) + if os.type == "windows" then + dirname = string.gsub(dirname, '/', '\\') + return os.execute('IF NOT EXIST ' .. dirname .. ' MKDIR ' .. dirname) + else + return os.execute('mkdir -p ' .. dirname) + end +end + for fd, v1 in pairs(foundry) do for _,s in pairs(v1[1]) do local dirname = fd print('koEmbed: ' .. dirname) - -- Linux しか想定していない - os.execute('mkdir ' .. dirname .. ' &>/dev/null') + mkdir(dirname) for mnx, mcont in pairs(maps) do if not string.match(mnx, '-04') or not foundry[fd].noncid then local mapbase = gsub(mnx, '@', dirname) diff --git a/tools/mkmap-ai0-sc.lua b/tools/mkmap-ai0-sc.lua index 01dc90f..03abbb7 100755 --- a/tools/mkmap-ai0-sc.lua +++ b/tools/mkmap-ai0-sc.lua @@ -134,12 +134,20 @@ local function make_one_line(o, fd, s) end end end +local function mkdir(dirname) + if os.type == "windows" then + dirname = string.gsub(dirname, '/', '\\') + return os.execute('IF NOT EXIST ' .. dirname .. ' MKDIR ' .. dirname) + else + return os.execute('mkdir -p ' .. dirname) + end +end + for fd, v1 in pairs(foundry) do for _,s in pairs(v1[1]) do local dirname = fd print('scEmbed: ' .. dirname) - -- Linux しか想定していない - os.execute('mkdir ' .. dirname .. ' &>/dev/null') + mkdir(dirname) for mnx, mcont in pairs(maps) do if not string.match(mnx, '-04') or not foundry[fd].noncid then local mapbase = gsub(mnx, '@', dirname) diff --git a/tools/mkmap-ai0-tc.lua b/tools/mkmap-ai0-tc.lua index 1c049fa..3b6d733 100755 --- a/tools/mkmap-ai0-tc.lua +++ b/tools/mkmap-ai0-tc.lua @@ -134,12 +134,20 @@ local function make_one_line(o, fd, s) end end end +local function mkdir(dirname) + if os.type == "windows" then + dirname = string.gsub(dirname, '/', '\\') + return os.execute('IF NOT EXIST ' .. dirname .. ' MKDIR ' .. dirname) + else + return os.execute('mkdir -p ' .. dirname) + end +end + for fd, v1 in pairs(foundry) do for _,s in pairs(v1[1]) do local dirname = fd print('tcEmbed: ' .. dirname) - -- Linux しか想定していない - os.execute('mkdir ' .. dirname .. ' &>/dev/null') + mkdir(dirname) for mnx, mcont in pairs(maps) do if not string.match(mnx, '-04') or not foundry[fd].noncid then local mapbase = gsub(mnx, '@', dirname) diff --git a/tools/mkmap-ja.lua b/tools/mkmap-ja.lua index fca1cea..a1e01a2 100755 --- a/tools/mkmap-ja.lua +++ b/tools/mkmap-ja.lua @@ -449,6 +449,15 @@ local function make_one_line(o, fd, s) end end +local function mkdir(dirname) + if os.type == "windows" then + dirname = string.gsub(dirname, '/', '\\') + return os.execute('IF NOT EXIST ' .. dirname .. ' MKDIR ' .. dirname) + else + return os.execute('mkdir -p ' .. dirname) + end +end + for fd, v1 in pairs(foundry) do -- separate でないときは mln などのデータベースを省略してあるので ml などからコピー if not foundry[fd].separate then @@ -464,8 +473,7 @@ for fd, v1 in pairs(foundry) do for _,s in pairs(v1[1]) do local dirname = fd .. suffix[s][2] print('jaEmbed: ' .. dirname) - -- Linux しか想定していない - os.execute('mkdir ' .. dirname .. ' &>/dev/null') + mkdir(dirname) for mnx, mcont in pairs(maps) do --if not string.match(mnx, '-04') or string.match(s, jis2004_flag) then -- フォントが OpenType (CID) の場合は、すべての map を作る diff --git a/tools/mkmap-ko.lua b/tools/mkmap-ko.lua index 7c94664..376a90d 100755 --- a/tools/mkmap-ko.lua +++ b/tools/mkmap-ko.lua @@ -180,12 +180,20 @@ local function make_one_line(o, fd, s) end end +local function mkdir(dirname) + if os.type == "windows" then + dirname = string.gsub(dirname, '/', '\\') + return os.execute('IF NOT EXIST ' .. dirname .. ' MKDIR ' .. dirname) + else + return os.execute('mkdir -p ' .. dirname) + end +end + for fd, v1 in pairs(foundry) do for _,s in pairs(v1[1]) do local dirname = fd .. suffix[s][2] print('koEmbed: ' .. dirname) - -- Linux しか想定していない - os.execute('mkdir ' .. dirname .. ' &>/dev/null') + mkdir(dirname) for mnx, mcont in pairs(maps) do --if not string.match(mnx, '-04') or string.match(s, jis2004_flag) then if not string.match(mnx, '-04') or not foundry[fd].noncid then diff --git a/tools/mkmap-sc.lua b/tools/mkmap-sc.lua index 8a310dc..ad6f8ac 100755 --- a/tools/mkmap-sc.lua +++ b/tools/mkmap-sc.lua @@ -216,12 +216,20 @@ local function make_one_line(o, fd, s) end end +local function mkdir(dirname) + if os.type == "windows" then + dirname = string.gsub(dirname, '/', '\\') + return os.execute('IF NOT EXIST ' .. dirname .. ' MKDIR ' .. dirname) + else + return os.execute('mkdir -p ' .. dirname) + end +end + for fd, v1 in pairs(foundry) do for _,s in pairs(v1[1]) do local dirname = fd .. suffix[s][2] print('scEmbed: ' .. dirname) - -- Linux しか想定していない - os.execute('mkdir ' .. dirname .. ' &>/dev/null') + mkdir(dirname) for mnx, mcont in pairs(maps) do --if not string.match(mnx, '-04') or string.match(s, jis2004_flag) then if not string.match(mnx, '-04') or not foundry[fd].noncid then diff --git a/tools/mkmap-tc.lua b/tools/mkmap-tc.lua index e35ce61..e671124 100755 --- a/tools/mkmap-tc.lua +++ b/tools/mkmap-tc.lua @@ -192,12 +192,20 @@ local function make_one_line(o, fd, s) end end +local function mkdir(dirname) + if os.type == "windows" then + dirname = string.gsub(dirname, '/', '\\') + return os.execute('IF NOT EXIST ' .. dirname .. ' MKDIR ' .. dirname) + else + return os.execute('mkdir -p ' .. dirname) + end +end + for fd, v1 in pairs(foundry) do for _,s in pairs(v1[1]) do local dirname = fd .. suffix[s][2] print('tcEmbed: ' .. dirname) - -- Linux しか想定していない - os.execute('mkdir ' .. dirname .. ' &>/dev/null') + mkdir(dirname) for mnx, mcont in pairs(maps) do --if not string.match(mnx, '-04') or string.match(s, jis2004_flag) then if not string.match(mnx, '-04') or not foundry[fd].noncid then