lib/nbl: When the pointer array is empty, don't output 0x800 0s.

This commit is contained in:
Loïc Hoguin 2010-10-03 04:17:52 +02:00
parent 1d14d8d54d
commit cd956a2aff

View File

@ -45,10 +45,16 @@ pack_files([], {AccH, AccD, AccP, _FilePos, _PtrIndex}) ->
BinD = iolist_to_binary(lists:reverse(AccD)), BinD = iolist_to_binary(lists:reverse(AccD)),
PaddingD = 8 * (16#800 - (byte_size(BinD) rem 16#800)), PaddingD = 8 * (16#800 - (byte_size(BinD) rem 16#800)),
BinP = iolist_to_binary(lists:reverse(AccP)), BinP = iolist_to_binary(lists:reverse(AccP)),
PaddingP = 8 * (16#800 - (byte_size(BinP) rem 16#800)), PtrSize = byte_size(BinP),
PtrArray = case PtrSize of
0 -> << >>;
_ ->
PaddingP = 8 * (16#800 - (byte_size(BinP) rem 16#800)),
<< BinP/binary, 0:PaddingP >>
end,
{<< BinH/binary, 0:PaddingH2 >>, {<< BinH/binary, 0:PaddingH2 >>,
<< BinD/binary, 0:PaddingD >>, byte_size(BinD), << BinD/binary, 0:PaddingD >>, byte_size(BinD),
<< BinP/binary, 0:PaddingP >>, byte_size(BinP)}; PtrArray, PtrSize};
pack_files([{data, Filename, Data, PtrList}|Tail], {AccH, AccD, AccP, FilePos, PtrIndex}) -> pack_files([{data, Filename, Data, PtrList}|Tail], {AccH, AccD, AccP, FilePos, PtrIndex}) ->
ID = case filename:extension(Filename) of ID = case filename:extension(Filename) of
".bin" -> << $S, $T, $D, 0 >>; ".bin" -> << $S, $T, $D, 0 >>;