diff options
author | Håkan Mattsson <[email protected]> | 2010-03-05 14:33:00 +0100 |
---|---|---|
committer | Håkan Mattsson <[email protected]> | 2010-03-16 14:28:25 +0100 |
commit | 26d609d3193c0adb371e27317fa0de7cda203061 (patch) | |
tree | f6eea3e93f67bea6343029c920a6dc7dd80f9901 /lib/reltool/src/reltool_utils.erl | |
parent | 31b790bdf8442a7eee22bfad0887d42278ffc18b (diff) | |
download | otp-26d609d3193c0adb371e27317fa0de7cda203061.tar.gz otp-26d609d3193c0adb371e27317fa0de7cda203061.tar.bz2 otp-26d609d3193c0adb371e27317fa0de7cda203061.zip |
Make reltool independent of the function escript:foldl/3
The function is undocumented and is removed. The new implementation
uses the newly introduced functions escript:extract/2 and
zip:foldl/3. These new functions are documented (which implies that
they are a part of the public API).
Diffstat (limited to 'lib/reltool/src/reltool_utils.erl')
-rw-r--r-- | lib/reltool/src/reltool_utils.erl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/reltool/src/reltool_utils.erl b/lib/reltool/src/reltool_utils.erl index 8d52ade9be..4de98317b5 100644 --- a/lib/reltool/src/reltool_utils.erl +++ b/lib/reltool/src/reltool_utils.erl @@ -532,6 +532,27 @@ default_val(Val, Default) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +escript_foldl(Fun, Acc, File) -> + case escript:extract(File, [compile_source]) of + {ok, [_Shebang, _Comment, _EmuArgs, Body]} -> + case Body of + {source, BeamCode} -> + GetInfo = fun() -> file:read_file_info(File) end, + GetBin = fun() -> BeamCode end, + {ok, Fun(".", GetInfo, GetBin, Acc)}; + {beam, BeamCode} -> + GetInfo = fun() -> file:read_file_info(File) end, + GetBin = fun() -> BeamCode end, + {ok, Fun(".", GetInfo, GetBin, Acc)}; + {archive, ArchiveBin} -> + zip:foldl(Fun, Acc, {File, ArchiveBin}) + end; + {error, Reason} -> + {error, Reason} + end. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + call(Name, Msg) when is_atom(Name) -> call(whereis(Name), Msg); call(Pid, Msg) when is_pid(Pid) -> |