Permalink
Browse files

added support for loading from a binary version of the image

  • Loading branch information...
1 parent fc320fc commit e3a93dad53e2b69d884ed9a405aa93acda1487a2 @alexgo alexgo committed Nov 7, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/erl_img.erl
View
@@ -114,9 +114,13 @@ read_file_info(File) ->
Error -> Error
end.
-
+load(Binary) when is_binary(Binary) ->
+ load_opt(Binary, [ram, binary, read]);
load(File) ->
- case file:open(File, [raw, binary, read]) of
+ load_opt(File, [raw, binary, read]).
+
+load_opt(File, Opts) ->
+ case file:open(File, Opts) of
{ok,Fd} ->
Res = case read_magic_info(Fd) of
{ok, IMG} ->
@@ -156,9 +160,6 @@ to_binary(IMG) ->
Error
end.
-
-
-
read_info(Type, Fd) ->
file:position(Fd, 0),
apply(Type, read_info, [Fd]).

0 comments on commit e3a93da

Please sign in to comment.