File: verify_language_files

package info (click to toggle)
wings3d 2.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,404 kB
  • sloc: erlang: 132,169; ansic: 3,779; lisp: 1,434; sh: 805; makefile: 794; cpp: 244; xml: 50
file content (42 lines) | stat: -rwxr-xr-x 1,045 bytes parent folder | download | duplicates (9)
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.