Lunatic/util: fixes for Windows.

- Need to open some files in binary mode.
- MinGW's "find" doesn't provide -L option, detect that.

git-svn-id: https://svn.eduke32.com/eduke32@4051 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-09-06 14:43:17 +00:00
parent 85aa90d82c
commit eef1977662
3 changed files with 13 additions and 9 deletions

View file

@ -76,12 +76,8 @@ MAX =
} }
local function doread(fh, basectype, numelts) local function doread(fh, basectype, numelts)
if (numelts==0) then assert(numelts > 0)
return nil
end
local cd = ffi.new(basectype.."[?]", numelts) local cd = ffi.new(basectype.."[?]", numelts)
local size = ffi.sizeof(basectype)*numelts
if (C.fread(cd, ffi.sizeof(basectype), numelts, fh) ~= numelts) then if (C.fread(cd, ffi.sizeof(basectype), numelts, fh) ~= numelts) then
fh:close() fh:close()
@ -206,7 +202,7 @@ end
-- } -- }
-- } -- }
function loadboard(filename, do_canonicalize_sprite) function loadboard(filename, do_canonicalize_sprite)
local fh, errmsg = io.open(filename) local fh, errmsg = io.open(filename, "rb")
if (fh==nil) then if (fh==nil) then
return nil, errmsg return nil, errmsg
@ -340,7 +336,7 @@ function loadarts(filenames)
for fni=1,#filenames do for fni=1,#filenames do
local fn = filenames[fni] local fn = filenames[fni]
local fh, errmsg = io.open(fn) local fh, errmsg = io.open(fn, "rb")
if (fh==nil) then if (fh==nil) then
return nil, errmsg return nil, errmsg

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
ok=yes ok=yes
if [ -z "$1" ]; then if [ -z "$1" ]; then
@ -13,4 +13,10 @@ if [ -z "$ok" ]; then
exit 1 exit 1
fi fi
find -L "$1" -iname '*.map' -print0 | xargs -0 ./foreachmap.lua "-e$2" LOPT=-L
idx=$(expr match `uname -s` '[mM][iI][nN][gG][wW]')
if [ "$idx" != 0 ]; then
LOPT=
fi
find $LOPT "$1" -iname '*.map' -print0 | xargs -0 ./foreachmap.lua "-e$2"

View file

@ -20,6 +20,8 @@
-- The local 'd' provides defs loaded from ../../names.h, example: -- The local 'd' provides defs loaded from ../../names.h, example:
-- $ ./findmaps.sh ~/.eduke32/ "sprite: .picnum>=d. CRACK1 and .picnum<=d. CRACK4" -- $ ./findmaps.sh ~/.eduke32/ "sprite: .picnum>=d. CRACK1 and .picnum<=d. CRACK4"
-- (The space between "d." and "CRACK" is because ".xxx" is translated to
-- "sprite[<current>].xxx".)
-- Print all V9 maps along with their number of bunches and max(ceilings of a bunch) -- Print all V9 maps along with their number of bunches and max(ceilings of a bunch)
-- $ prog='if (map.version==9) then print(map.numbunches.." ".. math.max(unpack(map.sectsperbunch[0],0)) .." "..fn) end' -- $ prog='if (map.version==9) then print(map.numbunches.." ".. math.max(unpack(map.sectsperbunch[0],0)) .." "..fn) end'