diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-07 14:00:36 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-07 14:00:36 +0100 |
| commit | dbdec09ea1dba290da41622184593fce85f57411 (patch) | |
| tree | 942ac9d89d34783365e4ccf7b162a9907658bdcb /src | |
| parent | 69b37beaa98f45bd4520f075bf16b3b96d28936a (diff) | |
| download | rabbitmq-server-git-dbdec09ea1dba290da41622184593fce85f57411.tar.gz | |
use filelib2 instead of filelib in most cases in queue_index and misc
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_misc.erl | 8 | ||||
| -rw-r--r-- | src/rabbit_queue_index.erl | 18 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index e8542574a7..3d2132e30c 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -587,7 +587,7 @@ append_file(File, _, Suffix) -> end. ensure_parent_dirs_exist(Filename) -> - case filelib:ensure_dir(Filename) of + case filelib2:ensure_dir(Filename) of ok -> ok; {error, Reason} -> throw({error, {cannot_create_parent_dirs, Filename, Reason}}) @@ -749,7 +749,7 @@ recursive_delete(Files) -> end, ok, Files). recursive_delete1(Path) -> - case filelib:is_dir(Path) of + case filelib2:is_dir(Path) of false -> case file2:delete(Path) of ok -> ok; {error, enoent} -> ok; %% Path doesn't exist anyway @@ -778,7 +778,7 @@ recursive_delete1(Path) -> end. recursive_copy(Src, Dest) -> - case filelib:is_dir(Src) of + case filelib2:is_dir(Src) of false -> case file2:copy(Src, Dest) of {ok, _Bytes} -> ok; {error, enoent} -> ok; %% Path doesn't exist anyway @@ -896,7 +896,7 @@ build_acyclic_graph(VertexFun, EdgeFun, Graph) -> %% TODO: When we stop supporting Erlang prior to R14, this should be %% replaced with file:open [write, exclusive] lock_file(Path) -> - case filelib:is_file(Path) of + case filelib2:is_file(Path) of true -> {error, eexist}; false -> {ok, Lock} = file2:open(Path, [write]), ok = file2:close(Lock) diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl index d7ed270970..2d8f63546f 100644 --- a/src/rabbit_queue_index.erl +++ b/src/rabbit_queue_index.erl @@ -229,7 +229,7 @@ init(Name, OnSyncFun) -> State = #qistate { dir = Dir } = blank_state(Name), - false = filelib:is_file(Dir), %% is_file == is file or dir + false = filelib2:is_file(Dir), %% is_file == is file or dir State #qistate { on_sync = OnSyncFun }. shutdown_terms(Name) -> @@ -368,7 +368,7 @@ recover(DurableQueues) -> all_queue_directory_names(Dir) -> case file2:list_dir(Dir) of {ok, Entries} -> [ Entry || Entry <- Entries, - filelib:is_dir( + filelib2:is_dir( filename:join(Dir, Entry)) ]; {error, enoent} -> [] end. @@ -402,7 +402,7 @@ read_shutdown_terms(Dir) -> store_clean_shutdown(Terms, Dir) -> CleanFileName = clean_file_name(Dir), - ok = filelib:ensure_dir(CleanFileName), + ok = filelib2:ensure_dir(CleanFileName), rabbit_misc:write_term_file(CleanFileName, Terms). init_clean(RecoveredCounts, State) -> @@ -603,7 +603,7 @@ flush_journal(State = #qistate { segments = Segments }) -> Segments1 = segment_fold( fun (#segment { unacked = 0, path = Path }, SegmentsN) -> - case filelib:is_file(Path) of + case filelib2:is_file(Path) of true -> ok = file2:delete(Path); false -> ok end, @@ -630,7 +630,7 @@ append_journal_to_segment(#segment { journal_entries = JEntries, get_journal_handle(State = #qistate { journal_handle = undefined, dir = Dir }) -> Path = filename:join(Dir, ?JOURNAL_FILENAME), - ok = filelib:ensure_dir(Path), + ok = filelib2:ensure_dir(Path), {ok, Hdl} = file_handle_cache:open(Path, ?WRITE_MODE, [{write_buffer, infinity}]), {Hdl, State #qistate { journal_handle = Hdl }}; @@ -735,7 +735,7 @@ all_segment_nums(#qistate { dir = Dir, segments = Segments }) -> lists:takewhile(fun (C) -> $0 =< C andalso C =< $9 end, SegName)), Set) end, sets:from_list(segment_nums(Segments)), - filelib:wildcard("*" ++ ?SEGMENT_EXTENSION, Dir)))). + filelib2:wildcard("*" ++ ?SEGMENT_EXTENSION, Dir)))). segment_find_or_new(Seg, Dir, Segments) -> case segment_find(Seg, Segments) of @@ -836,7 +836,7 @@ segment_entries_foldr(Fun, Init, %% %% Does not do any combining with the journal at all. load_segment(KeepAcked, #segment { path = Path }) -> - case filelib:is_file(Path) of + case filelib2:is_file(Path) of false -> {array_new(), 0}; true -> {ok, Hdl} = file_handle_cache:open(Path, ?READ_AHEAD_MODE, []), {ok, 0} = file_handle_cache:position(Hdl, bof), @@ -1040,12 +1040,12 @@ foreach_queue_index(Funs) -> transform_queue(Dir, Gatherer, {JournalFun, SegmentFun}) -> ok = transform_file(filename:join(Dir, ?JOURNAL_FILENAME), JournalFun), [ok = transform_file(filename:join(Dir, Seg), SegmentFun) - || Seg <- filelib:wildcard("*" ++ ?SEGMENT_EXTENSION, Dir)], + || Seg <- filelib2:wildcard("*" ++ ?SEGMENT_EXTENSION, Dir)], ok = gatherer:finish(Gatherer). transform_file(Path, Fun) -> PathTmp = Path ++ ".upgrade", - case filelib:file_size(Path) of + case filelib2:file_size(Path) of 0 -> ok; Size -> {ok, PathTmpHdl} = file_handle_cache:open(PathTmp, ?WRITE_MODE, |
