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

17
LINES

< > BotCompany Repo | #1024337 // copyAllFilesInDirectory_rec_noOverwrite - fails when it is supposed to overwrite a file

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (1764L/12K).

1  
svoid copyAllFilesInDirectory_rec_noOverwrite(File src, File dest) ctex {
2  
  print("Listing " + f2s(src));
3  
  for (File f : listFiles(src)) {
4  
    print("Copying " + f2s(f));
5  
    File destFile = newFile(dest, f.getName());
6  
    if (fileExists(destFile))
7  
      fail("Won't overwrite " + f2s(destFile) + " with contents of " + f2s(f));
8  
    if (isSymLink(f))
9  
      Files.createLink(fileToPath(destFile), fileToPath(f).toRealPath());
10  
    else if (isFile(f))
11  
      copyFile(f, destFile);
12  
    else if (isDirectory(f)) {
13  
      mkdirs(destFile);
14  
      copyAllFilesInDirectory_rec_noOverwrite(f, newFile(dest, f.getName()));
15  
    }
16  
  }
17  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024337
Snippet name: copyAllFilesInDirectory_rec_noOverwrite - fails when it is supposed to overwrite a file
Eternal ID of this version: #1024337/8
Text MD5: 52692abf8cf322b9bc3790f94f12d72d
Transpilation MD5: 7eec6368525b01e59cfea4077bece2c3
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-04 13:45:42
Source code size: 639 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 268 / 361
Version history: 7 change(s)
Referenced in: [show references]