I've this piece of code flying around:
function searchfile(file_name::String, root_folder::String)
file_name == "" && return ""
files_folders = readdir(root_folder)
folders = filter(x->isdir(joinpath(root_folder, x)),
files_folders)
files = filter(x->!isdir(joinpath(root_folder, x)),
files_folders)
results = filter(x-> x == file_name, files)
if !isempty(results)
return joinpath(root_folder, first(results))
elseif isempty(folders)
return ""
else
for folder in folders
result = searchfile(file_name, joinpath(root_folder, folder))
result != "" && return result
end
end
return ""
end
Am Samstag, 14. März 2015 19:41:38 UTC+1 schrieb Andreas Lobinger:
>
> Hello colleagues,
>
> is there a simple method to search for data files (so not code) along a
> given path?
> data_path = ['/usr/local_data','/opt/all_data']
> f = find_file("a.data",data_path);
>
> Wishing a happy day,
> Andreas
>