summaryrefslogtreecommitdiff
path: root/src/index.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.erl')
-rw-r--r--src/index.erl11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/index.erl b/src/index.erl
index bbc9a10..c1e0352 100644
--- a/src/index.erl
+++ b/src/index.erl
@@ -77,6 +77,17 @@ decodedata(<<_:?ENTRYSIZE/binary-unit:16, _>>, _Acc) ->
util:exit_with_error(badformat, readindex,
"Index line not ending with linefeed").
+-spec size(string()) -> integer().
+size(Basepath) ->
+ case file:open(Basepath, [read, binary]) of
+ {ok, File} ->
+ {ok, Filesize} = file:position(File, eof),
+ Filesize mod ?ENTRYSIZEINFILE;
+ {error, Error} ->
+ util:exit_with_error(Error, readfile,
+ "Error opening file for reading")
+ end.
+
-spec get(string(), integer()) -> binary().
get(Basepath, Index) ->
case getrange(Basepath, Index, Index) of