private static File fileReallyExists(URL ret, String fileWithoutPackage) { File path; try { /* fix for GROOVY-5809 */ path = new File(ret.toURI()); } catch(URISyntaxException e) { path = new File(decodeFileName(ret.getFile())); } path = path.getParentFile(); if (path.exists() && path.isDirectory()) { File file = new File(path, fileWithoutPackage); if (file.exists()) { // file.exists() might be case insensitive. Let's do // case sensitive match for the filename File parent = file.getParentFile(); for (String child : parent.list()) { if (child.equals(fileWithoutPackage)) return file; } } } //file does not exist! return null; }
private File getFileForUrl(URL ret, String filename) { String fileWithoutPackage = filename; if (fileWithoutPackage.indexOf('/') != -1) { int index = fileWithoutPackage.lastIndexOf('/'); fileWithoutPackage = fileWithoutPackage.substring(index + 1); } File path = new File(decodeFileName(ret.getFile())).getParentFile(); if (path.exists() && path.isDirectory()) { File file = new File(path, fileWithoutPackage); if (file.exists()) { // file.exists() might be case insensitive. Let's do // case sensitive match for the filename File parent = file.getParentFile(); String[] files = parent.list(); for (int j = 0; j < files.length; j++) { if (files[j].equals(fileWithoutPackage)) return file; } } } //file does not exist! return null; }
private File fileReallyExists(URL ret, String fileWithoutPackage) { File path; try { /* fix for GROOVY-5809 */ path = new File(ret.toURI()); } catch(URISyntaxException e) { path = new File(decodeFileName(ret.getFile())); } path = path.getParentFile(); if (path.exists() && path.isDirectory()) { File file = new File(path, fileWithoutPackage); if (file.exists()) { // file.exists() might be case insensitive. Let's do // case sensitive match for the filename File parent = file.getParentFile(); for (String child : parent.list()) { if (child.equals(fileWithoutPackage)) return file; } } } //file does not exist! return null; }
private URL getSourceFile(String name) { String filename = name.replace('.', '/') + config.getDefaultScriptExtension(); URL ret = getResource(filename); if (ret != null && ret.getProtocol().equals("file")) { String fileWithoutPackage = filename; if (fileWithoutPackage.indexOf('/') != -1) { int index = fileWithoutPackage.lastIndexOf('/'); fileWithoutPackage = fileWithoutPackage.substring(index + 1); } File path = new File(decodeFileName(ret.getFile())).getParentFile(); if (path.exists() && path.isDirectory()) { File file = new File(path, fileWithoutPackage); if (file.exists()) { // file.exists() might be case insensitive. Let's do // case sensitive match for the filename File parent = file.getParentFile(); String[] files = parent.list(); for (int j = 0; j < files.length; j++) { if (files[j].equals(fileWithoutPackage)) return ret; } } } //file does not exist! return null; } return ret; }
private URL getSourceFile(String name) { String filename = name.replace('.', '/') + config.getDefaultScriptExtension(); URL ret = getResource(filename); if (ret != null && ret.getProtocol().equals("file")) { String fileWithoutPackage = filename; if (fileWithoutPackage.indexOf('/') != -1) { int index = fileWithoutPackage.lastIndexOf('/'); fileWithoutPackage = fileWithoutPackage.substring(index + 1); } File path = new File(decodeFileName(ret.getFile())).getParentFile(); if (path.exists() && path.isDirectory()) { File file = new File(path, fileWithoutPackage); if (file.exists()) { // file.exists() might be case insensitive. Let's do // case sensitive match for the filename File parent = file.getParentFile(); String[] files = parent.list(); for (int j = 0; j < files.length; j++) { if (files[j].equals(fileWithoutPackage)) return ret; } } } //file does not exist! return null; } return ret; }