/* * Create_Scratch_Buffer.bsh - a BeanShell macro script to rapidly create * temporary buffers in a specified directory * * Copyright (C) 2005 Jeroen Budts, http://dev.budts.be * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You can download the most recent version of this macro (and probably others) * from my DARCS repository: * $ darcs get http://dev.budts.be/darcs/jedit-macros */ private final String PATH = "I:/scratch-buffers/"; //should end with a slash (/) private final String PREFIX = ""; private final String SUFFIX = ".scratch"; // =================== no need to modify below this line ======================= private final char[] ALLOWED_C = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'z', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'q', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'w', 'x', 'c', 'v', 'b', 'n'}; private final int NAME_LEN = 10; private final long SEED = 19831019; void CreateNewScratchBuffer() { Random r = new Random(SEED); boolean isValidPath(String path) { return new File(path).isDirectory(); } String getFullFileName(String randomPart) { return PATH+PREFIX+randomPart+SUFFIX; } char getRandomChar() { return ALLOWED_C[r.nextInt(ALLOWED_C.length)]; } String generateRandomString(int length) { StringBuilder s = new StringBuilder(); for (int i=0; i