Skip to content

Commit

Permalink
Merge pull request erlang#7711 from josevalim/jv-which-read-file-info
Browse files Browse the repository at this point in the history
Avoid listing code path directories
OTP-18816
  • Loading branch information
frazze-jobb authored Oct 23, 2023
2 parents dd57c85 + 20f3c11 commit 95de100
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/kernel/src/code.erl
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,7 @@ which(Module, Path) when is_atom(Module) ->
File = atom_to_list(Module) ++ objfile_extension(),
where_is_file(Path, File).

%% Search the code path for a specific file. Try to locate
%% it in the code path cache if possible.
%% Search the code path for a specific file.

-spec where_is_file(Filename) -> non_existing | Absname when
Filename :: file:filename(),
Expand All @@ -880,9 +879,10 @@ where_is_file([], _) ->
where_is_file([{Path, Files}|Tail], File) ->
where_is_file(Tail, File, Path, Files);
where_is_file([Path|Tail], File) ->
case erl_prim_loader:list_dir(Path) of
{ok,Files} ->
where_is_file(Tail, File, Path, Files);
Full = filename:append(Path, File),
case erl_prim_loader:read_file_info(Full) of
{ok,_} ->
Full;
_Error ->
where_is_file(Tail, File)
end.
Expand Down

0 comments on commit 95de100

Please sign in to comment.