Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1001725 // findAllFiles (scans recursively, returns files & dirs)

JavaX fragment (include)

1  
static L<File> findAllFiles(L dirs) {
2  
  ret findAllFiles(asObjectArray(dirs));
3  
}
4  
5  
// dirs are String's or File's
6  
static L<File> findAllFiles(O... dirs) {
7  
  new L<File> l;
8  
  for (O dir : dirs) {
9  
    if (dir cast S && dir.endsWith("/."))
10  
      // "/." means non-recurse
11  
      for (File f : listFiles(dropSuffix("/.", dir)))
12  
        l.add(f);
13  
    else
14  
      findAllFiles_impl(toFile(dir), l);
15  
  }
16  
  ret l;
17  
}
18  
19  
static void findAllFiles_impl(File dir, L<File> l) {
20  
  for (File f : listFiles(dir)) {
21  
    l.add(f);
22  
    if (f.isDirectory())
23  
      findAllFiles_impl(f, l);
24  
  }
25  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001725
Snippet name: findAllFiles (scans recursively, returns files & dirs)
Eternal ID of this version: #1001725/2
Text MD5: 47f3e6327ff868d79c9a93174d19d3e9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-30 05:30:29
Source code size: 594 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 597 / 927
Version history: 1 change(s)
Referenced in: [show references]