private static ZipEntry getZipEntryFor(byte[] bytes, int begin, int end) { int ix = end; for (int i = 0; i < end; i++) { if (bytes[begin + i] == '!') { ix = i; break; } } if (ix == end) return null; String fileName = newStringFromUTF8(bytes, begin + 5, ix - 5); String entryName = newStringFromUTF8(bytes, begin + ix + 1, end - (ix + 1)); if (entryName.startsWith("/")) entryName = entryName.substring(1); try { return RubyFile.getDirOrFileEntry(fileName, entryName); } catch (Exception e) {} return null; }
private static ByteList fixBytesForJarInUTF8(byte[] buf, int offset, int len) { String path = newStringFromUTF8(buf, offset, len); path = path.replace(".jar/", ".jar!"); return new ByteList(path.getBytes()); }
private static ByteList fixBytesForJarInUTF8(byte[] buf, int offset, int len) { String path = newStringFromUTF8(buf, offset, len); path = path.replace(".jar/", ".jar!"); return new ByteList(path.getBytes()); }
private static int addToResultIfExists(String cwd, byte[] bytes, int begin, int end, int flags, GlobFunc func, GlobArgs arg) { String fileName = newStringFromUTF8(bytes, begin, end - begin); JavaSecuredFile file = cwd != null ? new JavaSecuredFile(cwd, fileName) : new JavaSecuredFile(fileName);
private static int addToResultIfExists(String cwd, byte[] bytes, int begin, int end, int flags, GlobFunc func, GlobArgs arg) { String fileName = newStringFromUTF8(bytes, begin, end - begin); FileResource file = JRubyFile.createResource(cwd, fileName);
st = new JavaSecuredFile(newStringFromUTF8(dir)); } else if(isJarFilePath(dir, 0, dir.length)) { int ix = dir.length; st = new JavaSecuredFile(newStringFromUTF8(dir, 5, ix-5)); if(ix<dir.length) { jar = newStringFromUTF8(dir, ix+1, dir.length-(ix+1)); try { jf = new JarFile(st); st = new JavaSecuredFile(cwd, newStringFromUTF8(dir)); buf.append(getBytesInUTF8(dirp[i])); if (isAbsolutePath(buf.getUnsafeBytes(), buf.getBegin(), buf.getRealSize())) { st = new JavaSecuredFile(newStringFromUTF8(buf.getUnsafeBytes(), buf.getBegin(), buf.getRealSize())); } else { st = new JavaSecuredFile(cwd, newStringFromUTF8(buf.getUnsafeBytes(), buf.getBegin(), buf.getRealSize())); if (status == 0) { if(isAbsolutePath(b.getUnsafeBytes(), b.begin(), b.getRealSize())) { st = new JavaSecuredFile(newStringFromUTF8(b.getUnsafeBytes(), 0, b.getRealSize())); } else { st = new JavaSecuredFile(cwd, newStringFromUTF8(b.getUnsafeBytes(), 0, b.getRealSize()));
boolean recursive = false; st = JRubyFile.createResource(cwd, newStringFromUTF8(dir)); buf.append(isRoot(base) ? EMPTY : SLASH ); buf.append(getBytesInUTF8(dirp[i])); st = JRubyFile.createResource(cwd, newStringFromUTF8(buf.getUnsafeBytes(), buf.getBegin(), buf.getRealSize())); if(!st.isSymLink() && st.isDirectory() && !".".equals(dirp[i]) && !"..".equals(dirp[i])) { int t = buf.getRealSize(); ByteList b = globber.link; if (status == 0) { st = JRubyFile.createResource(cwd, newStringFromUTF8(b.getUnsafeBytes(), 0, b.getRealSize())); if(st.isDirectory()) { int len = b.getRealSize();