-
Notifications
You must be signed in to change notification settings - Fork 91
/
verify_language_files
executable file
·42 lines (38 loc) · 1.02 KB
/
verify_language_files
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env escript
%% -*- erlang -*-
%%
%% verify_language_files --
%%
%% Verify that all language files are consultable.
%%
%% Copyright (c) 2007 Bjorn Gustavsson
%%
%% See the file "license.terms" for information on usage and redistribution
%% of this file, and for a DISCLAIMER OF ALL WARRANTIES.
%%
main([Root]) ->
Files = filelib:fold_files(Root, ".lang$", true,
fun(N, Acc) -> [N|Acc] end, []),
case verify_files(Files, 0) of
0 ->
halt(0);
N ->
io:format("~p error(s)\n", [N]),
receive after 100 -> ok end,
halt(1)
end;
main(_) ->
io:put_chars("usage: verify_language_files RootDirectory\n"),
halt(1).
verify_files([F|Fs], Errors) ->
case file:consult(F) of
{ok,_} ->
verify_files(Fs, Errors);
{error,{Line,Mod,Reason}} ->
io:format("~s:~p: ~p\n", [F,Line,Mod:format_error(Reason)]),
verify_files(Fs, Errors+1);
{error,Reason} ->
io:format("~s: ~p\n", [F,Reason]),
verify_files(Fs, Errors+1)
end;
verify_files([], Errors) -> Errors.