1 | static void readLocally(S progID, S varNames) {
|
2 | readLocally2(mc(), progID, varNames); |
3 | } |
4 | |
5 | static void readLocally(S varNames) {
|
6 | readLocally2(mc(), programID(), varNames); |
7 | } |
8 | |
9 | static void readLocally2(O obj, S varNames) {
|
10 | readLocally2(obj, programID(), varNames); |
11 | } |
12 | |
13 | static int readLocally_stringLength; |
14 | |
15 | static new ThreadLocal<Bool> readLocally2_allDynamic; |
16 | static new ThreadLocal readLocally2_classFinder; |
17 | |
18 | // read a string variable from standard storage |
19 | // does not overwrite variable contents if there is no file |
20 | static void readLocally2(O obj, S progID, S varNames) ctex {
|
21 | bool allDynamic = isTrue(getAndClearThreadLocal(readLocally2_allDynamic)); |
22 | for (S variableName : javaTokC(varNames)) {
|
23 | File textFile = new File(programDir(progID), variableName + ".text"); |
24 | |
25 | S value = loadTextFile(textFile); |
26 | if (value != null) |
27 | set(main.class, variableName, value); |
28 | else {
|
29 | File structureFile = new File(programDir(progID), variableName + ".structure"); |
30 | value = loadTextFile(structureFile); |
31 | |
32 | if (value == null) {
|
33 | File structureGZFile = new File(programDir(progID), variableName + ".structure.gz"); |
34 | if (!structureGZFile.isFile()) ret; |
35 | //value = loadGZTextFile(structureGZFile); |
36 | temp InputStream fis = new FileInputStream(structureGZFile); |
37 | GZIPInputStream gis = newGZIPInputStream(fis); |
38 | InputStreamReader reader = new InputStreamReader(gis, "UTF-8"); |
39 | BufferedReader bufferedReader = new BufferedReader(reader); |
40 | //O o = unstructure_reader(bufferedReader); |
41 | O o = unstructure_tok(javaTokC_noMLS_onReader(bufferedReader), allDynamic, readLocally2_classFinder!); |
42 | readLocally_set(obj, variableName, o); |
43 | ret; |
44 | } |
45 | |
46 | readLocally_stringLength = l(value); |
47 | if (nempty(value)) |
48 | readLocally_set(obj, variableName, unstructure(value, allDynamic, readLocally2_classFinder!)); |
49 | } |
50 | } |
51 | } |
52 | |
53 | static void readLocally_set(O c, S varName, O value) {
|
54 | O oldValue = get(c, varName); |
55 | if (oldValue instanceof List && !(oldValue instanceof ArrayList) && value != null) {
|
56 | // Assume it's a synchroList. |
57 | value = synchroList((L) value); |
58 | } |
59 | set(c, varName, value); |
60 | } |
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: | #1001043 |
| Snippet name: | readLocally / readLocally2 |
| Eternal ID of this version: | #1001043/6 |
| Text MD5: | d2ad8621336fa25777fe33ab29f44ba3 |
| Author: | stefan |
| Category: | |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-07-13 22:34:40 |
| Source code size: | 2272 bytes / 60 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1427 / 3154 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |