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

32
LINES

< > BotCompany Repo | #1001044 // saveLocally / saveLocally2

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

Libraryless. Click here for Pure Java version (4506L/27K).

static void saveLocally(S variableName) {
  saveLocally(programID(), variableName);
}

static void saveLocally(S progID, S variableName) {
  saveLocally2(mc(), progID, variableName);
}

static void saveLocally2(O obj, S variableName) {
  saveLocally2(obj, programID(), variableName);
}

static File saveLocally2(O obj, S progID, S variableName) {
  lock saveLock();
  File textFile = new File(programDir(progID), variableName + ".text");
  File structureFile = new File(programDir(progID), variableName + ".structure");
  O x = get(obj, variableName);
  
  if (x == null) {
    textFile.delete();
    structureFile.delete();
    null;
  } else if (x instanceof String) {
    saveTextFile(textFile, (S) x);
    structureFile.delete();
    ret textFile;
  } else {
    saveTextFile(structureFile, javaTokWordWrap(structure(x)));
    textFile.delete();
    ret structureFile;
  }
}

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: #1001044
Snippet name: saveLocally / saveLocally2
Eternal ID of this version: #1001044/4
Text MD5: 35e1dfdbec4885ac8854f4ee91c371b2
Transpilation MD5: 048d25ae4217c9a164915b4164128649
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-14 16:31:46
Source code size: 909 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 703 / 2479
Version history: 3 change(s)
Referenced in: [show references]