Skip to content

Instantly share code, notes, and snippets.

@Vesnica
Created February 2, 2013 20:10
Show Gist options
  • Save Vesnica/4699054 to your computer and use it in GitHub Desktop.
Save Vesnica/4699054 to your computer and use it in GitHub Desktop.
.xfl extractor (Liar Soft)
-module(xfl).
-author("Wisher").
-email("hustitecwisher@gmail.com").
-export([extract/1]).
% All bgm is ogg format, but have a 66 bytes fake wave header.(Liar...)
extract(File) ->
{ok, Bin} = file:read_file(File),
<<_:32, Size:32/little, Items:32/little, Rest/binary>> = Bin,
lists:foldl(fun(_, B) ->
<<N:32/binary, S:32/little, Len:32/little, B1/binary>> = B,
Fake = lists:takewhile(fun(A) -> A =/= 0 end, binary_to_list(N)),
Name = re:replace(Fake, ".wav", ".ogg", [{return, list}]),
io:format("Name:~p~n", [Name]),
file:write_file(Name, binary_part(Rest, S + Size + 66, Len - 66)),
B1
end, Rest, lists:duplicate(Items, 0)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment