Libraryless. Click here for Pure Java version (4002L/25K).
static long saveGZStructureToFile(S file, O o) { ret saveGZStructureToFile(getProgramFile(file), o); } // returns number of uncompressed bytes written static long saveGZStructureToFile(File file, O o, structure_Data data default new) ctex { File parentFile = file.getParentFile(); if (parentFile != null) parentFile.mkdirs(); File tempFile = tempFileFor(file); if (tempFile.exists()) try { S saveName = tempFile.getPath() + ".saved." + now(); copyFile(tempFile, new File(saveName)); } catch (Throwable e) { printStackTrace(e); } FileOutputStream fileOutputStream = newFileOutputStream(tempFile.getPath()); CountingOutputStream cos; try { GZIPOutputStream gos = new GZIPOutputStream(fileOutputStream); cos = new CountingOutputStream(gos); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(cos, "UTF-8"); PrintWriter printWriter = new PrintWriter(outputStreamWriter); structureToPrintWriter(o, printWriter, data); printWriter.close(); gos.close(); fileOutputStream.close(); } catch e { fileOutputStream.close(); tempFile.delete(); throw rethrow(e); } if (file.exists() && !file.delete()) throw new IOException("Can't delete " + file.getPath()); if (!tempFile.renameTo(file)) throw new IOException("Can't rename " + tempFile + " to " + file); ret cos.getFilePointer(); }
Began life as a copy of #1005539
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1005970 |
| Snippet name: | saveGZStructureToFile |
| Eternal ID of this version: | #1005970/8 |
| Text MD5: | 82913a82f8106e0b24bc5512bc5b9b86 |
| Transpilation MD5: | ff7f58b664d28dfb404e2e8a7641ab0a |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-04-14 16:27:27 |
| Source code size: | 1426 bytes / 40 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 930 / 1097 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |