Libraryless. Click here for Pure Java version (2790L/17K).
1 | static File renameFile_assertTrue(File a, File b) ctex {
|
2 | if (a.equals(b)) ret b; // no rename necessary |
3 | if (!a.exists()) fail("Source file not found: " + f2s(a));
|
4 | if (b.exists()) fail("Target file exists: " + f2s(b));
|
5 | mkdirsForFile(b); |
6 | ifdef renameFile_useNIO |
7 | java.nio.file.Files.move(a.toPath(), b.toPath()); |
8 | endifdef |
9 | ifndef renameFile_useNIO |
10 | if (!a.renameTo(b)) |
11 | fail("Can't rename " + f2s(a) + " to " + f2s(b));
|
12 | endifndef |
13 | ret b; |
14 | } |
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: | 715 / 872 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |