Add directory selector
nfuryn opened this issue · 3 comments
So I have tried to make a directory selector by switching extensions to "", which did hide all the files, however when opening each directory it still takes a long time to load because it still checks all the files in that directory.
I propose that you add an additional switch in the options panel, e.g. file_browser_server("files", path = "~", directory_view = TRUE) and have it applied in R/utils-get-files-dirs.R:
get_files_dirs_real <- function(path, extensions = NULL, hidden = FALSE, root = NULL) {
if (directory_view == TRUE){
all_files <- list.dirs(path = path, all.files = hidden, full.names = TRUE, recursive = FALSE, no.. = TRUE)
} else {
all_files <- list.files(path = path, all.files = hidden, full.names = TRUE, recursive = FALSE, no.. = TRUE)
}}
Sorry, I am not used to using github yet to suggest/push the right way.
Thanks for the suggestion. I couldn't use your code because (1) unfortunately list.dirs()
doesn't take the same parameters as list.files()
and doesn't quite work in the same way (that's quite annoying!) , and (2) I want to try to avoid adding extra parameters, as there are already more than enough.
I did refactor the code and now it's much faster to load a directory. You can re-install the latest version and see.
I also added a comment in the documentation of extensions
saying that ""
results in only folders and no files.
Ah, I didn't really take the time to read the documentation as I just assumed that it would just mirror list.files :)
Thank you, it works much faster now!