Refactor the code into separate files

Separate repository/odb functions into their own file. Add odb_exists
to go through the repository's odb. Adjust the test script.
This commit is contained in:
Carlos Martín Nieto
2012-08-14 02:22:46 +02:00
parent a6c03f17df
commit 27e72e5173
6 changed files with 176 additions and 59 deletions

View File

@@ -1,5 +1,5 @@
-module(geef).
-export([hex_to_raw/1, object_exists/2, repository/1, repository_path/1]).
-export([hex_to_raw/1, object_exists/2, repository/1, repository_path/1, repository_odb/1, odb_exists/2]).
-on_load(load_enif/0).
hex_to_raw(_Val) ->
@@ -14,6 +14,9 @@ repository_open(_Val) ->
repository_get_path(_Val) ->
nif_error(?LINE).
repository_get_odb(_Val) ->
nif_error(?LINE).
repository_path({repository, Handle}) ->
repository_get_path(Handle).
@@ -21,6 +24,16 @@ repository(Path) ->
{ok, Repository} = repository_open(Path),
{repository, Repository}.
repository_odb({repository, Handle}) ->
{ok, Odb} = repository_get_odb(Handle),
{odb, Odb}.
odb_object_exists(_Val, _Val) ->
nif_error(?LINE).
odb_exists({odb, Handle}, Sha) ->
odb_object_exists(Handle, Sha).
nif_error(Line) ->
exit({nif_not_loaded,module,?MODULE,line,Line}).