-
Notifications
You must be signed in to change notification settings - Fork 9
/
code_compare.erl
32 lines (30 loc) · 1.24 KB
/
code_compare.erl
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
%% @copyright Geoff Cant 2010
%% @author Geoff Cant <[email protected]>
%% @version {@vsn}, {@date} {@time}
%% @doc Compare loaded with disk code.
%% @end
f(CmpModule).
CmpModule = fun (Module) ->
Secs = fun ({YY,MM,DD,H,M,S}) ->
calendar:datetime_to_gregorian_seconds({{YY,MM,DD},{H,M,S}})
end,
{file, File} = code:is_loaded(Module),
{ok, {Module, [{compile_info, CI}]}} = beam_lib:chunks(File, [compile_info]),
LoadedTime = proplists:get_value(time, Module:module_info(compile)),
DiskTime = proplists:get_value(time, CI),
case LoadedTime of
DiskTime -> in_sync;
_ ->
[{loaded, LoadedTime},
{disk, DiskTime},
{disk_is_newer,
Secs(DiskTime) -
Secs(LoadedTime)
}]
end
end.
f(CmpApp).
CmpApp = fun (App) ->
[{M, CmpModule(M)}
|| M <- element(2, application:get_key(App, modules))]
end.