Using fileext to filter directory files
- Posted by K_D_R Feb 01, 2012
- 1237 views
My latest tweaks to the routines that load directory files into ed.ex's file_history sequence.
fileext is used to select only file specs contained in E_FILES.
procedure load_startup_directory_files() -- load E_FILES into file_history: object tmp = {} tmp = dir("*.*") if not atom(tmp)then if length(tmp)>1 then for x = 1 to length(tmp) do if find("." & fileext(tmp[x][D_NAME]), E_FILES) then --<--------- file_history = update_history(file_history, tmp[x][D_NAME]) end if end for end if end if end procedure procedure load_files_from_new_directory(sequence path) -- load E_FILES into file_history -- an absolute path is created by prepending -- the path to the new directory object tmp = {} tmp = dir("*.*") if not atom(tmp)then if length(tmp)>1 then for x = 1 to length(tmp) do if find("." & fileext(tmp[x][D_NAME]), E_FILES) then --<--------- file_history = update_history(file_history, sprintf("%s", {path & SLASH & tmp[x][D_NAME]})) end if end for command_history = update_history(command_history, sprintf("ls %s", {path & SLASH})) command_history = update_history(command_history, sprintf("ls *.ex *.e %s", {path & SLASH})) end if end if end procedure