Created
March 28, 2013 15:55
-
-
Save ir4y/5264340 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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