Be able to find all contents of a directory (#3711)

This commit is contained in:
Orion Poplawski 2016-11-21 15:20:53 -07:00 committed by Matt Clay
parent 78f8ef267c
commit ade7b47f28

View file

@ -66,7 +66,7 @@ options:
required: false required: false
description: description:
- Type of file to select - Type of file to select
choices: [ "file", "directory", "link" ] choices: [ "file", "directory", "link", "any" ]
default: "file" default: "file"
recurse: recurse:
required: false required: false
@ -275,7 +275,7 @@ def main():
paths = dict(required=True, aliases=['name','path'], type='list'), paths = dict(required=True, aliases=['name','path'], type='list'),
patterns = dict(default=['*'], type='list', aliases=['pattern']), patterns = dict(default=['*'], type='list', aliases=['pattern']),
contains = dict(default=None, type='str'), contains = dict(default=None, type='str'),
file_type = dict(default="file", choices=['file', 'directory', 'link'], type='str'), file_type = dict(default="file", choices=['file', 'directory', 'link', 'any'], type='str'),
age = dict(default=None, type='str'), age = dict(default=None, type='str'),
age_stamp = dict(default="mtime", choices=['atime','mtime','ctime'], type='str'), age_stamp = dict(default="mtime", choices=['atime','mtime','ctime'], type='str'),
size = dict(default=None, type='str'), size = dict(default=None, type='str'),
@ -337,7 +337,11 @@ def main():
continue continue
r = {'path': fsname} r = {'path': fsname}
if stat.S_ISDIR(st.st_mode) and params['file_type'] == 'directory': if params['file_type'] == 'any':
if pfilter(fsobj, params['patterns'], params['use_regex']) and agefilter(st, now, age, params['age_stamp']):
r.update(statinfo(st))
filelist.append(r)
elif stat.S_ISDIR(st.st_mode) and params['file_type'] == 'directory':
if pfilter(fsobj, params['patterns'], params['use_regex']) and agefilter(st, now, age, params['age_stamp']): if pfilter(fsobj, params['patterns'], params['use_regex']) and agefilter(st, now, age, params['age_stamp']):
r.update(statinfo(st)) r.update(statinfo(st))