DIRECTORY.entries

6 views
Skip to first unread message

Larry Rix

unread,
Feb 24, 2020, 3:50:53 PM2/24/20
to Eiffel Users
Once we have a {DIRECTORY} object with 'entries', how do we determine which entries are subfolder directories and which are files easily and quickly?

Gachoud Philippe

unread,
Feb 24, 2020, 5:07:59 PM2/24/20
to eiffel...@googlegroups.com
Hi Larry,

personally I used DIRECTORY_ITERATOR which process_directory implementation holds differences between files and directories, I redefined this method to separate directories and files

Hope it helps

On Mon, Feb 24, 2020 at 5:50 PM Larry Rix <lar...@moonshotsoftware.com> wrote:
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.


--
**********************************************
Philippe Gachoud
Puerto Williams 6657
Las Condes
Santiago de Chile
+56 934022210
ph.ga...@gmail.com
**********************************************

Finnian Reilly

unread,
Feb 25, 2020, 6:39:20 AM2/25/20
to eiffel...@googlegroups.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

Reply all
Reply to author
Forward
0 new messages