1 | static void saveStructureToFile(S file, O o) { |
2 | saveStructureToFile(getProgramFile(file), o); |
3 | } |
4 | |
5 | static void saveStructureToFile(File file, O o) ctex { |
6 | File parentFile = file.getParentFile(); |
7 | if (parentFile != null) |
8 | parentFile.mkdirs(); |
9 | File tempFile = tempFileFor(file); |
10 | if (tempFile.exists()) try { |
11 | S saveName = tempFile.getPath() + ".saved." + now(); |
12 | copyFile(tempFile, new File(saveName)); |
13 | } catch (Throwable e) { printStackTrace(e); } |
14 | |
15 | FileOutputStream fileOutputStream = newFileOutputStream(tempFile.getPath()); |
16 | try { |
17 | OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8"); |
18 | PrintWriter printWriter = new PrintWriter(outputStreamWriter); |
19 | structureToPrintWriter(o, printWriter); |
20 | printWriter.close(); |
21 | fileOutputStream.close(); |
22 | } catch e { |
23 | fileOutputStream.close(); |
24 | tempFile.delete(); |
25 | throw rethrow(e); |
26 | } |
27 | |
28 | if (file.exists() && !file.delete()) |
29 | throw new IOException("Can't delete " + file.getPath()); |
30 | |
31 | if (!tempFile.renameTo(file)) |
32 | throw new IOException("Can't rename " + tempFile + " to " + file); |
33 | } |
Began life as a copy of #1005970
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: | #1014165 |
Snippet name: | saveStructureToFile - no .gz |
Eternal ID of this version: | #1014165/1 |
Text MD5: | 385a0ebdb516585ceebe641fd46fcbd4 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-04-15 14:21:40 |
Source code size: | 1149 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 351 / 375 |
Referenced in: | [show references] |