private static boolean isRoot(byte[] base) { int length = base.length; return length == 0 || // empty length == 1 && isdirsep(base[0]) || // Just '/' length == 3 && beginsWithDriveLetter(base, 0, length); // Just X:/ }
private static byte[] extract_elem(byte[] bytes, int begin, int end) { int elementEnd = indexOf(bytes, begin, end, (byte)'/'); if (elementEnd == -1) elementEnd = end; return extract_path(bytes, begin, elementEnd); }
if (isDoubleStarAndSlash(bytes, pat_pos)) { do { pat_pos += 3; } while (isDoubleStarAndSlash(bytes, pat_pos)); ptmp = pat_pos; stmp = str_pos; int patSlashIdx = nextSlashIndex(bytes, pat_pos, pend); int strSlashIdx = nextSlashIndex(string, str_pos, send); if (fnmatch_helper(bytes, pat_pos, patSlashIdx, string, str_pos, strSlashIdx, flags) == 0) { if (patSlashIdx < pend && strSlashIdx < send) { stmp = nextSlashIndex(string, stmp, send); if (stmp < send) { pat_pos = ptmp; return fnmatch_helper(bytes, pstart, pend, string, sstart, send, flags);
private static byte[] extract_elem(byte[] bytes, int begin, int end) { int elementEnd = strchr(bytes, begin, end, (byte)'/'); if (elementEnd == -1) elementEnd = end; return extract_path(bytes, begin, elementEnd); }
if (!has_magic(bytes, p, end, flags)) { if (DOSISH || (flags & FNM_NOESCAPE) == 0) { newpath = new byte[end]; if (sub != -1) { p = (sub - begin); end = remove_backslashes(newpath, p, end); sub = p; } else { end = remove_backslashes(newpath, 0, end); bytes = newpath; if (isAbsolutePath(bytes, begin, end)) { status = addToResultIfExists(null, bytes, begin, end, flags, func, arg); } else if (isJarFilePath(bytes, begin, end)) { if (getZipEntryFor(bytes, begin, end) != null) { status = func.call(bytes, begin, end, arg); status = addToResultIfExists(cwd, bytes, begin, end, flags, func, arg); m = strchr(bytes, p, end, (byte)'/'); if(has_magic(bytes, p, m == -1 ? end : m, flags)) { finalize: do { byte[] base = extract_path(bytes, begin, p); byte[] dir = begin == p ? new byte[]{'.'} : base; byte[] magic = extract_elem(bytes,p,end); boolean recursive = false; String jar = null; JarFile jf = null;
if (!has_magic(bytes, p, end, flags)) { if (DOSISH || (flags & FNM_NOESCAPE) == 0) { newpath = new byte[end]; if (sub != -1) { p = (sub - begin); end = remove_backslashes(newpath, p, end); sub = p; } else { end = remove_backslashes(newpath, 0, end); bytes = newpath; if (isAbsolutePath(bytes, begin, end)) { status = addToResultIfExists(null, bytes, begin, end, flags, func, arg); } else if ((end - begin) > 0) { // Length check is a hack. We should not be reeiving "" as a filename ever. status = addToResultIfExists(cwd, bytes, begin, end, flags, func, arg); m = strchr(bytes, p, end, (byte)'/'); if(has_magic(bytes, p, m == -1 ? end : m, flags)) { finalize: do { byte[] base = extract_path(bytes, begin, p); byte[] dir = begin == p ? new byte[]{'.'} : base; byte[] magic = extract_elem(bytes,p,end); boolean recursive = false; st = JRubyFile.createResource(cwd, newStringFromUTF8(dir)); buf.append(base); buf.append(bytes, (base.length > 0 ? m : m + 1), end - (base.length > 0 ? m : m + 1));
if ( ! has_magic(path, ptr, end, flags) ) { if ( DOSISH || (flags & FNM_NOESCAPE) == 0 ) { if ( sub != -1 ) { // can modify path (our internal buf[]) end = remove_backslashes(path, sub, end); final byte[] newPath = new byte[len]; System.arraycopy(path, begin, newPath, 0, len); begin = 0; end = remove_backslashes(newPath, 0, len); path = newPath; if ( isAbsolutePath(path, begin, end) ) { status = addToResultIfExists(runtime, null, path, begin, end, enc, flags, func, arg); } else { status = addToResultIfExists(runtime, cwd, path, begin, end, enc, flags, func, arg); final int SLASH_INDEX = indexOf(path, ptr, end, (byte) '/'); if (has_magic(path, ptr, SLASH_INDEX == -1 ? end : SLASH_INDEX, flags) ) { finalize: do { byte[] base = extract_path(path, begin, ptr); byte[] dir = begin == ptr ? new byte[] { '.' } : base; byte[] magic = extract_elem(path, ptr, end); boolean recursive = false; do { nextStartIndex = indexOfSlash + 1; indexOfSlash = indexOf(path, nextStartIndex, end, (byte) '/'); magic = extract_elem(path, nextStartIndex, end); } while(Arrays.equals(magic, DOUBLE_STAR) && indexOfSlash != -1);
switch(c) { case '?': if(s >= send || (pathname && isdirsep(string[s])) || (period && string[s] == '.' && (s == 0 || (pathname && isdirsep(string[s-1]))))) { return FNM_NOMATCH; case '*': while(pat < pend && (c = (char)(bytes[pat++] & 0xFF)) == '*') {} if(s < send && (period && string[s] == '.' && (s == 0 || (pathname && isdirsep(string[s-1]))))) { return FNM_NOMATCH; if(pathname && rb_path_next(string, s, send) < send) { return FNM_NOMATCH; } else { return 0; } else if((pathname && isdirsep(c))) { s = rb_path_next(string, s, send); if(s < send) { s++; while(s < send) { if((c == '?' || c == '[' || Character.toLowerCase((char) string[s]) == test) && fnmatch(bytes, pat, pend, string, s, send, flags | FNM_DOTMATCH) == 0) { return 0; } else if((pathname && isdirsep(string[s]))) { break; if(s >= send || (pathname && isdirsep(string[s]) ||
private static int push_globs(Ruby runtime, String cwd, List<ByteList> ary, ByteList pattern, int flags) { flags |= FNM_SYSCASE; return glob_helper(runtime, cwd, pattern, -1, flags, glob_caller, new GlobArgs(push_pattern, ary)); }
private static boolean dir_fnmatch(ByteList pattern, ByteList path, int flags) { return org.jruby.util.Dir.fnmatch(pattern.getUnsafeBytes(), pattern.getBegin(), pattern.getBegin()+pattern.getRealSize(), path.getUnsafeBytes(), path.getBegin(), path.getBegin()+path.getRealSize(), flags) == 0; }
if ( ! has_magic(path, ptr, end, flags) ) { if ( DOSISH || (flags & FNM_NOESCAPE) == 0 ) { if ( sub != -1 ) { // can modify path (our internal buf[]) end = remove_backslashes(path, sub, end); final byte[] newPath = new byte[len]; System.arraycopy(path, begin, newPath, 0, len); begin = 0; end = remove_backslashes(newPath, 0, len); path = newPath; if ( isAbsolutePath(path, begin, end) ) { status = addToResultIfExists(runtime, null, path, begin, end, enc, flags, func, arg); } else { status = addToResultIfExists(runtime, cwd, path, begin, end, enc, flags, func, arg); final int SLASH_INDEX = indexOf(path, ptr, end, (byte) '/'); if (has_magic(path, ptr, SLASH_INDEX == -1 ? end : SLASH_INDEX, flags) ) { finalize: do { byte[] base = extract_path(path, begin, ptr); byte[] dir = begin == ptr ? new byte[] { '.' } : base; byte[] magic = extract_elem(path, ptr, end); boolean recursive = false; do { nextStartIndex = indexOfSlash + 1; indexOfSlash = indexOf(path, nextStartIndex, end, (byte) '/'); magic = extract_elem(path, nextStartIndex, end); } while(Arrays.equals(magic, DOUBLE_STAR) && indexOfSlash != -1);
switch(c) { case '?': if(s >= send || (pathname && isdirsep(string[s])) || (period && string[s] == '.' && (s == 0 || (pathname && isdirsep(string[s-1]))))) { return FNM_NOMATCH; case '*': while(pat < pend && (c = (char)(bytes[pat++] & 0xFF)) == '*') {} if(s < send && (period && string[s] == '.' && (s == 0 || (pathname && isdirsep(string[s-1]))))) { return FNM_NOMATCH; if(pathname && rb_path_next(string, s, send) < send) { return FNM_NOMATCH; } else { return 0; } else if((pathname && isdirsep(c))) { s = rb_path_next(string, s, send); if(s < send) { s++; while(s < send) { if((c == '?' || c == '[' || Character.toLowerCase((char) string[s]) == test) && fnmatch(bytes, pat, pend, string, s, send, flags | FNM_DOTMATCH) == 0) { return 0; } else if((pathname && isdirsep(string[s]))) { break; if(s >= send || (pathname && isdirsep(string[s]) ||
private static int push_globs(Ruby runtime, String cwd, List<ByteList> ary, ByteList pattern, int flags) { flags |= FNM_SYSCASE; return glob_helper(runtime, cwd, pattern, -1, flags, glob_caller, new GlobArgs(push_pattern, ary)); }
private static byte[] extract_elem(byte[] bytes, int begin, int end) { int elementEnd = strchr(bytes, begin, end, (byte)'/'); if (elementEnd == -1) elementEnd = end; return extract_path(bytes, begin, elementEnd); }
private static boolean dir_fnmatch(ByteList pattern, ByteList path, int flags) { return org.jruby.util.Dir.fnmatch(pattern.getUnsafeBytes(), pattern.getBegin(), pattern.getBegin()+pattern.getRealSize(), path.getUnsafeBytes(), path.getBegin(), path.getBegin()+path.getRealSize(), flags) == 0; }
switch(c) { case '?': if(s >= send || (pathname && isdirsep(string[s])) || (period && string[s] == '.' && (s == 0 || (pathname && isdirsep(string[s-1]))))) { return FNM_NOMATCH; case '*': while(pat < pend && (c = bytes[pat++]) == '*') {} if(s < send && (period && string[s] == '.' && (s == 0 || (pathname && isdirsep(string[s-1]))))) { return FNM_NOMATCH; if(pathname && rb_path_next(string, s, send) < send) { return FNM_NOMATCH; } else { return 0; } else if((pathname && isdirsep(c))) { s = rb_path_next(string, s, send); if(s < send) { s++; while(s < send) { if((c == '?' || c == '[' || Character.toLowerCase((char) string[s]) == test) && fnmatch(bytes, pat, pend, string, s, send, flags | FNM_DOTMATCH) == 0) { return 0; } else if((pathname && isdirsep(string[s]))) { break; if(s >= send || (pathname && isdirsep(string[s]) ||
if (isDoubleStarAndSlash(bytes, pat_pos)) { do { pat_pos += 3; } while (isDoubleStarAndSlash(bytes, pat_pos)); ptmp = pat_pos; stmp = str_pos; int patSlashIdx = nextSlashIndex(bytes, pat_pos, pend); int strSlashIdx = nextSlashIndex(string, str_pos, send); if (fnmatch_helper(bytes, pat_pos, patSlashIdx, string, str_pos, strSlashIdx, flags) == 0) { if (patSlashIdx < pend && strSlashIdx < send) { stmp = nextSlashIndex(string, stmp, send); if (stmp < send) { pat_pos = ptmp; return fnmatch_helper(bytes, pstart, pend, string, sstart, send, flags);
private static boolean isRoot(byte[] base) { int length = base.length; return length == 0 || // empty length == 1 && isdirsep(base[0]) || // Just '/' length == 3 && beginsWithDriveLetter(base, 0, length); // Just X:/ }
private static int push_globs(String cwd, List<ByteList> ary, byte[] pattern, int pbegin, int pend, int pflags) { pflags |= FNM_SYSCASE; return glob_helper(cwd, pattern, pbegin, pend, -1, pflags, glob_caller, new GlobArgs(push_pattern, ary)); }
private static byte[] extract_elem(byte[] bytes, int begin, int end) { int elementEnd = indexOf(bytes, begin, end, (byte)'/'); if (elementEnd == -1) elementEnd = end; return extract_path(bytes, begin, elementEnd); }