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
Snippet ID: | #1002703 |
Snippet name: | Show File, Delete File command (master) |
Eternal ID of this version: | #1002703/1 |
Text MD5: | c752f3c879a0fa9dfde13b47d3b04bfc |
Transpilation MD5: | adf33a1a9ade137f5c012e4208f808ed |
Author: | stefan |
Category: | nl bots |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-03-10 18:56:59 |
Source code size: | 1522 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 634 / 931 |
Referenced in: | [show references] |