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 is a S && ((S) dir).endsWith("/."))
      // "/." means non-recurse
      for (File f : listFiles(dropSuffix("/.", (S) 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   

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

No comments. add comment

Snippet ID: #1001725
Snippet name: findAllFiles (scans recursively, returns files & dirs)
Eternal ID of this version: #1001725/1
Text MD5: 6d22b910fe09c0d4f920311abf2a9695
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-26 22:16:35
Source code size: 604 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 402 / 641
Referenced in: [show references]

Formerly at http://tinybrain.de/1001725 & http://1001725.tinybrain.de