Once we have a {DIRECTORY} object with 'entries', how do we determine which entries are subfolder directories and which are files easily and quickly?
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/c58bc628-6781-4ed7-8b66-8bf754358202%40googlegroups.com.
personally I used DIRECTORY_ITERATOR which process_directory implementation holds differences between files and directories, I redefined this method to separate directories and files
Slow method
I like to use EL_DIRECTORY (inherits DIRECTORY and accessible via EL_SHARED DIRECTORY) which offers the following possibilities
directories: EL_ARRAYED_LIST [EL_DIR_PATH] directories_with_extension (extension: READABLE_STRING_GENERAL): EL_ARRAYED_LIST [EL_DIR_PATH] entries: EL_ARRAYED_LIST [EL_PATH] entries_with_extension (extension: READABLE_STRING_GENERAL): EL_ARRAYED_LIST [EL_PATH] files: EL_SORTABLE_ARRAYED_LIST [EL_FILE_PATH] files_with_extension (extension: READABLE_STRING_GENERAL): like files recursive_directories: like directories recursive_files: like files recursive_files_with_extension (extension: READABLE_STRING_GENERAL): like files
Fast method
For recursive listings I also use EL_OS_ROUTINES_I accessible via EL_MODULE_OS which offers
directory_list (a_dir_path: EL_DIR_PATH): like Find_directories_cmd.path_list file_list (a_dir_path: EL_DIR_PATH; a_file_pattern: READABLE_STRING_GENERAL): EL_FILE_PATH_LIST
Benchmarks
Despite the fact that the latter routines have to read the
results from disk, they are still approximately 30% faster than
the former routines because they make use of the native
Linux/Windows commands find/dir respectively. These OS
commands are highly optimized.
Benchmark to read C files from W_code directory (approx 4.2 K
files)
SELECTED: Compare finding files with extension Benchmark: list_w_code_c_files Getting average time: el_directory (of 10 runs) Getting average time: el_os_routines_i (of 10 runs) Average execution times (in ascending order) el_os_routines_i : 651.500 millisecs el_directory : +53%
-- Finnian