-
Notifications
You must be signed in to change notification settings - Fork 1
/
find_and_list.m
41 lines (37 loc) · 1.58 KB
/
find_and_list.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function result = find_and_list(root_folder_path, is_file_a_keeper_predicate)
seed = cell(1,0) ;
result = file_accumulate_map_filter(root_folder_path, seed, @accumulator, @mapper, is_file_a_keeper_predicate) ;
end
function result = accumulator(result_so_far, file_value)
result = horzcat(result_so_far, {file_value}) ;
end
function result = mapper(root_folder_path, base_folder_relative_path, file_name, depth) %#ok<INUSD>
result = fullfile(root_folder_path, base_folder_relative_path, file_name) ;
end
%
% function list = ...
% find_and_list_helper(base_folder_path, ...
% is_file_a_keeper_predicate, ...
% initial_list, ...
% varargin)
% list = initial_list ;
% [file_names, is_file_a_folder] = simple_dir(base_folder_path) ;
% file_count = length(file_names) ;
% for i = 1 : file_count ,
% file_name = file_names{i} ;
% is_this_file_a_folder = is_file_a_folder(i) ;
% file_path = fullfile(base_folder_path, file_name) ;
% if is_this_file_a_folder ,
% % if a folder, recurse
% list = ...
% find_and_list_helper(file_path, ...
% is_file_a_keeper_predicate, ...
% list, ...
% varargin{:}) ;
% else
% if feval(is_file_a_keeper_predicate, file_path, varargin{:}) ,
% list = horzcat(list, {file_path}) ; %#ok<AGROW>
% end
% end
% end
% end