Skip to content

Instantly share code, notes, and snippets.

@ir4y
Created March 28, 2013 15:55
Show Gist options
  • Save ir4y/5264340 to your computer and use it in GitHub Desktop.
Save ir4y/5264340 to your computer and use it in GitHub Desktop.
-module(find).
-export([find/2,walker/1]).
find(Re_name,Path) ->
io:format(file:read_file_info(Path)).
walker({dir_item,FileInfo,Path}) ->
case FileInfo of
{file_info,_,directory,_,_,_,_,_,_,_,_,_,_,_} ->
{ok,FileList} = file:list_dir(Path),
%todo spawn outher thread
walker(Path,FileList);
{file_info,_,regular,_,_,_,_,_,_,_,_,_,_,_} -> [{Path}]
end;
walker(Path) ->
{ok,FileInfo} = file:read_file_info(Path),
walker({dir_item,FileInfo,Path}).
walker(Path,[]) -> [{Path}];
walker(Path,[H|T]) ->
walker(Path ++ "/" ++ H) ++ walker(Path,T).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment