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

14
LINES

< > BotCompany Repo | #1011776 // renameFile_assertTrue

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

Libraryless. Click here for Pure Java version (2790L/17K).

static File renameFile_assertTrue(File a, File b) ctex {
  if (a.equals(b)) ret b; // no rename necessary
  if (!a.exists()) fail("Source file not found: " + f2s(a));
  if (b.exists()) fail("Target file exists: " + f2s(b));
  mkdirsForFile(b);
  ifdef renameFile_useNIO
    java.nio.file.Files.move(a.toPath(), b.toPath());
  endifdef
  ifndef renameFile_useNIO
  if (!a.renameTo(b))
    fail("Can't rename " + f2s(a) + " to " + f2s(b));
  endifndef
  ret b;
}

Author comment

Began life as a copy of #1002706

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1011776
Snippet name: renameFile_assertTrue
Eternal ID of this version: #1011776/5
Text MD5: 401373a83487220f0cf2afb7a3ad3ad1
Transpilation MD5: 57daa7693edcc584d48007011d24bde7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-29 21:49:39
Source code size: 473 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 462 / 567
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1011777 - renameFile_forceOverwrite