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)

static L<File> findAllFiles(L dirs) {
  ret findAllFiles(asObjectArray(dirs));
}

// dirs are String's or File's
static L<File> findAllFiles(O... dirs) {
  new L<File> l;
  for (O dir : dirs) {
    if (dir cast S && dir.endsWith("/."))
      // "/." means non-recurse
      for (File f : listFiles(dropSuffix("/.", dir)))
        l.add(f);
    else
      findAllFiles_impl(toFile(dir), l);
  }
  ret l;
}

static void findAllFiles_impl(File dir, L<File> l) {
  for (File f : listFiles(dir)) {
    l.add(f);
    if (f.isDirectory())
      findAllFiles_impl(f, l);
  }
}

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: 589 / 915
Version history: 1 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1003844 - findAllFiles_noDirs (scans recursively, returns files only)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#3000382 - Answer for ferdie (>> t = 1, f = 0)