Libraryless. Click here for Pure Java version (1299L/9K/30K).
!752 answer { if (!master()) ret null; if "show file *" exceptionToUser { File file = pathToFile(m.unq(0)); if (!file.exists()) ret format("File * not found", file.getPath()); if (file.isDirectory()) ret "It's a directory"; ret slackSnippet(loadTextFile(file)); } if "delete file *" exceptionToUser { File file = pathToFile(m.unq(0)); if (!file.exists()) ret format("File * not found", file.getPath()); if (file.isDirectory()) ret "It's a directory"; File delFile = getProgramFile("deleted at " + uniqueNow() + " from " + urlencode(file.getAbsolutePath())); if (renameFile(file, delFile)) ret "OK, backed up as " + delFile.getPath(); else ret format("Hm. Could not rename * to *", file.getPath(), delFile.getPath()); } if "copy file * to *" exceptionToUser { File file = pathToFile(m.unq(0)); File dest = pathToFile(m.unq(1)); if (!file.exists()) ret format("File * not found", file.getPath()); if (file.isDirectory()) ret "It's a directory"; if (dest.isFile()) ret format("File * exists", dest.getPath()); if (dest.isDirectory()) dest = new File(dest, file.getName()); copyFile(file, dest); ret "OK, copied " + file.getPath() + " to " + dest.getPath(); } } static File pathToFile(S path) { if (!path.startsWith("#")) path = "#" + path; assertFalse(path.indexOf("..") >= 0); ret new File(javaxDataDir(), path); }
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