This commit is contained in:
Scott Lystig Fritchie 2015-10-21 17:22:27 +09:00
parent d2ac5b0583
commit 0c4c42cc52
3 changed files with 14 additions and 5 deletions

View file

@ -189,8 +189,8 @@ find_file(DataDir, Prefix, N) ->
filelib:wildcard(Path).
list_files(DataDir, Prefix) ->
{F, Path} = machi_util:make_data_filename(DataDir, Prefix, "*", "*"),
filelib:wildcard(F, filename:dirname(Path)).
{F_bin, Path} = machi_util:make_data_filename(DataDir, Prefix, "*", "*"),
filelib:wildcard(binary_to_list(F_bin), filename:dirname(Path)).
make_filename_mgr_name(FluName) when is_atom(FluName) ->
list_to_atom(atom_to_list(FluName) ++ "_filename_mgr").

View file

@ -228,7 +228,7 @@ clear_ets(Tid, Mref) ->
update_ets(Tid, R#md{ proxy_pid = undefined, mref = undefined }).
purge_ets(Tid, R) ->
ok = ets:delete_object(Tid, R).
true = ets:delete_object(Tid, R).
get_md_record_by_mref(Tid, Mref) ->
[R] = ets:match_object(Tid, {md, '_', '_', Mref}),

View file

@ -90,11 +90,20 @@ make_checksum_filename(DataDir, FileName) ->
%% @doc Calculate a file data file path, by common convention.
-spec make_data_filename(string(), string(), atom()|string()|binary(), integer()) ->
-spec make_data_filename(string(), string(), atom()|string()|binary(), integer()|string()) ->
{binary(), string()}.
make_data_filename(DataDir, Prefix, SequencerName, FileNum) ->
make_data_filename(DataDir, Prefix, SequencerName, FileNum)
when is_integer(FileNum) ->
File = erlang:iolist_to_binary(io_lib:format("~s^~s^~w",
[Prefix, SequencerName, FileNum])),
make_data_filename2(DataDir, File);
make_data_filename(DataDir, Prefix, SequencerName, String)
when is_list(String) ->
File = erlang:iolist_to_binary(io_lib:format("~s^~s^~s",
[Prefix, SequencerName, string])),
make_data_filename2(DataDir, File).
make_data_filename2(DataDir, File) ->
FullPath = lists:flatten(io_lib:format("~s/data/~s", [DataDir, File])),
{File, FullPath}.