Add geef_odb:write

This commit is contained in:
Carlos Martín Nieto
2013-03-30 14:19:05 +01:00
parent 5ee6b055e9
commit 125e132af9
7 changed files with 58 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
-module(geef).
-export([hex_to_raw/1, reference_list/1,
reference_to_id/2, reference_glob/2, reference_lookup/2, reference_resolve/1,
reference_target/1, reference_type/1, odb_object_exists/2]).
reference_target/1, reference_type/1, odb_object_exists/2, odb_write/3]).
% repository operations
-export([repository_get_path/1, repository_get_odb/1, repository_open/1, repository_init/2,
@@ -65,6 +65,10 @@ reference_type(_Handle) ->
odb_object_exists(_Val, _Val) ->
nif_error(?LINE).
-spec odb_write(term, iolist(), atom()) -> term.
odb_write(_Handle, _Contents, _Type) ->
nif_error(?LINE).
oid_fmt(_Oid) ->
nif_error(?LINE).

View File

@@ -1,8 +1,17 @@
-module(geef_odb).
-export([exists/2]).
-export([exists/2, write/3]).
-include("geef_records.hrl").
-spec exists(odb(), string()) -> boolean().
exists(#odb{handle=Handle}, Sha) ->
geef:odb_object_exists(Handle, Sha).
-spec write(odb(), iolist(), atom()) -> {ok, oid()} | {error, term}.
write(#odb{handle=Handle}, Contents, Type) ->
case geef:odb_write(Handle, Contents, Type) of
{ok, Oid} ->
{ok, #oid{oid=Oid}};
Other ->
Other
end.