Refactor file list generation for 'files' and 'dir' section

Dedicated file list generation function 's:sanitize_file_list' and
simplification of cwd filtering in 'dir' section