Skip to content

Commit 1074586

Browse files
opoplawskibcoca
authored andcommitted
Be able to find all contents of a directory (ansible#3711)
1 parent 7903b39 commit 1074586

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

files/find.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
required: false
6767
description:
6868
- Type of file to select
69-
choices: [ "file", "directory", "link" ]
69+
choices: [ "file", "directory", "link", "any" ]
7070
default: "file"
7171
recurse:
7272
required: false
@@ -275,7 +275,7 @@ def main():
275275
paths = dict(required=True, aliases=['name','path'], type='list'),
276276
patterns = dict(default=['*'], type='list', aliases=['pattern']),
277277
contains = dict(default=None, type='str'),
278-
file_type = dict(default="file", choices=['file', 'directory', 'link'], type='str'),
278+
file_type = dict(default="file", choices=['file', 'directory', 'link', 'any'], type='str'),
279279
age = dict(default=None, type='str'),
280280
age_stamp = dict(default="mtime", choices=['atime','mtime','ctime'], type='str'),
281281
size = dict(default=None, type='str'),
@@ -337,7 +337,11 @@ def main():
337337
continue
338338

339339
r = {'path': fsname}
340-
if stat.S_ISDIR(st.st_mode) and params['file_type'] == 'directory':
340+
if params['file_type'] == 'any':
341+
if pfilter(fsobj, params['patterns'], params['use_regex']) and agefilter(st, now, age, params['age_stamp']):
342+
r.update(statinfo(st))
343+
filelist.append(r)
344+
elif stat.S_ISDIR(st.st_mode) and params['file_type'] == 'directory':
341345
if pfilter(fsobj, params['patterns'], params['use_regex']) and agefilter(st, now, age, params['age_stamp']):
342346

343347
r.update(statinfo(st))

0 commit comments

Comments
 (0)