-
-
Save binarytemple/50c995661d286f177276ce27a7979cf7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env escript | |
%% -*- erlang -*- | |
%%! -smp enable -sname convert_binary_ring -mnesia debug verbose | |
main([RingFile, OutFile]) -> | |
try | |
{ok, Binary} = file:read_file(RingFile), | |
Ring = binary_to_term(Binary), | |
try | |
file:write_file(OutFile, io_lib:format("~p.~n", [Ring])), | |
io:format("Saved ~p to ~p.~n", [RingFile, OutFile]) | |
catch | |
A:B -> | |
io:format("Exception ~p:~p~n",[A,B]) | |
end | |
catch | |
_:_ -> | |
usage() | |
end; | |
main([RingFile]) -> | |
main([RingFile, lists:append(RingFile,".txt")]); | |
main(_) -> | |
usage(). | |
usage() -> | |
io:format("usage: convert_binary_ring RingFile [OutputFile]\n"), | |
halt(1). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment