diff --git a/pe/lib_misc.erl b/pe/lib_misc.erl index 2eff783..1712672 100755 --- a/pe/lib_misc.erl +++ b/pe/lib_misc.erl @@ -6,7 +6,9 @@ perms/1, kabs/1, kfilter/2, - kclassify/1 + kclassify/1, + stash_term/2, + retrieve_term/1 ]). for(Max, Max, F) -> @@ -61,3 +63,13 @@ kclassify(N) -> true -> low end. + +stash_term(Path, Term) -> + file:write_file(Path, erlang:term_to_binary(Term)). + +retrieve_term(Path) -> + case file:read_file(Path) of + {ok, BinaryTerm} -> + erlang:binary_to_term(BinaryTerm); + {error, Reason} -> throw({read_file, Reason}) + end.