Top Description Inners Fields Constructors Methods
org.jruby.util

public Class Dir

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .Collections, .List, org.jcodings.Encoding, org.jcodings.specific.ASCIIEncoding, org.jruby.Ruby, .RubyEncoding, .RubyString, org.jruby.platform.Platform

This class exists as a counterpart to the dir.c file in MRI source. It contains many methods useful for File matching and Globbing.
Author
Ola Bini

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class
private static class
private static interface
pack-priv static enum
private static class

Field Summary

Modifier and TypeField and Description
public static final boolean
public static final boolean
public static final byte[]
public static final byte[]
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
private static final Dir.GlobFunc<Dir.GlobArgs>
private static final Dir.GlobFunc<List<ByteList>>
public static final byte[]
public static final byte[]

Constructor Summary

AccessConstructor and Description
public
Dir()

Method Summary

Modifier and TypeMethod and Description
private static int
addToResultIfExists(Ruby runtime, String cwd, byte[] bytes, int begin, int end, Encoding enc, int flags, Dir.GlobFunc<Dir.GlobArgs> func, Dir.GlobArgs arg)

private static boolean
beginsWithDriveLetter(byte[] path, int begin, int end)

public static ArrayList<String>
braces(String pattern, int flags, ArrayList<String> patterns)

private static byte[]
extract_elem(byte[] bytes, int begin, int end)

private static byte[]
extract_path(byte[] bytes, int begin, int end)

private static byte[]
extractScheme(byte[] path, int begin, int end)

private static String[]
files(final FileResource directory)

private static int
findScheme(byte[] path, int begin, int end)

public static int
fnmatch(byte[] bytes, int pstart, int pend, byte[] string, int sstart, int send, int flags)

public static int
fnmatch(byte[] bytes, int pstart, int pend, byte[] string, int sstart, int send, int flags, Encoding enc)

private static byte[]
private static int
glob_helper(Ruby runtime, String cwd, ByteList path, int sub, int flags, Dir.GlobFunc<Dir.GlobArgs> func, Dir.GlobArgs arg)

private static int
glob_helper(Ruby runtime, String cwd, byte[] scheme, ByteList path, int sub, int flags, Dir.GlobFunc<Dir.GlobArgs> func, Dir.GlobArgs arg)

private static int
glob_helper(Ruby runtime, String cwd, byte[] scheme, byte[] path, int begin, int end, Encoding enc, int sub, int flags, Dir.GlobFunc<Dir.GlobArgs> func, Dir.GlobArgs arg)

private static Dir.GlobMagic
has_magic(byte[] bytes, int begin, int end, int flags)

private static int
indexOf(byte[] bytes, int begin, int end, final byte ch)

private static boolean
isAbsolutePath(byte[] path, int begin, int length)

private static boolean
isAlpha(byte b)

private static boolean
isdirsep(int c)

private static boolean
isdirsep(byte c)

private static boolean
isDoubleStarAndSlash(byte[] bytes, int pos)

private static boolean
isRoot(byte[] base)

private static boolean
private static int
nextSlashIndex(byte[] bytes, int start, int end)

private static byte[]
prependScheme(byte[] scheme, byte[] path, int begin, int end)

private static int
push_braces(Ruby runtime, String cwd, List<ByteList> result, Dir.GlobPattern pattern, boolean sort)

public static List<ByteList>
push_glob(Ruby runtime, String cwd, ByteList globByteList, int flags, boolean sort)

private static int
push_globs(Ruby runtime, String cwd, List<ByteList> ary, ByteList pattern, int flags, boolean sort)

public static int
range(byte[] _pat, int pat, int pend, char test, int flags)
Deprecated No replacement; not intended to be made public

private static int
rb_path_next(byte[] _s, int s, int send)

private static int
remove_backslashes(byte[] bytes, int index, int end)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CASEFOLD_FILESYSTEMback to summary
public static final boolean CASEFOLD_FILESYSTEM
DOSISHback to summary
public static final boolean DOSISH
DOUBLE_STARback to summary
public static final byte[] DOUBLE_STAR
EMPTYback to summary
public static final byte[] EMPTY
FNM_CASEFOLDback to summary
public static final int FNM_CASEFOLD
FNM_DOTMATCHback to summary
public static final int FNM_DOTMATCH
FNM_ERRORback to summary
public static final int FNM_ERROR
FNM_GLOB_SKIPDOTback to summary
public static final int FNM_GLOB_SKIPDOT
FNM_NOESCAPEback to summary
public static final int FNM_NOESCAPE
FNM_NOMATCHback to summary
public static final int FNM_NOMATCH
FNM_PATHNAMEback to summary
public static final int FNM_PATHNAME
FNM_SYSCASEback to summary
public static final int FNM_SYSCASE
glob_callerback to summary
private static final Dir.GlobFunc<Dir.GlobArgs> glob_caller
push_patternback to summary
private static final Dir.GlobFunc<List<ByteList>> push_pattern
SLASHback to summary
public static final byte[] SLASH
STARback to summary
public static final byte[] STAR

Constructor Detail

Dirback to summary
public Dir()

Method Detail

addToResultIfExistsback to summary
private static int addToResultIfExists(Ruby runtime, String cwd, byte[] bytes, int begin, int end, Encoding enc, int flags, Dir.GlobFunc<Dir.GlobArgs> func, Dir.GlobArgs arg)
beginsWithDriveLetterback to summary
private static boolean beginsWithDriveLetter(byte[] path, int begin, int end)
bracesback to summary
public static ArrayList<String> braces(String pattern, int flags, ArrayList<String> patterns)
extract_elemback to summary
private static byte[] extract_elem(byte[] bytes, int begin, int end)
extract_pathback to summary
private static byte[] extract_path(byte[] bytes, int begin, int end)
extractSchemeback to summary
private static byte[] extractScheme(byte[] path, int begin, int end)
filesback to summary
private static String[] files(final FileResource directory)
findSchemeback to summary
private static int findScheme(byte[] path, int begin, int end)
fnmatchback to summary
public static int fnmatch(byte[] bytes, int pstart, int pend, byte[] string, int sstart, int send, int flags)
fnmatchback to summary
public static int fnmatch(byte[] bytes, int pstart, int pend, byte[] string, int sstart, int send, int flags, Encoding enc)
getBytesInUTF8back to summary
private static byte[] getBytesInUTF8(final String str)
glob_helperback to summary
private static int glob_helper(Ruby runtime, String cwd, ByteList path, int sub, int flags, Dir.GlobFunc<Dir.GlobArgs> func, Dir.GlobArgs arg)
glob_helperback to summary
private static int glob_helper(Ruby runtime, String cwd, byte[] scheme, ByteList path, int sub, int flags, Dir.GlobFunc<Dir.GlobArgs> func, Dir.GlobArgs arg)
glob_helperback to summary
private static int glob_helper(Ruby runtime, String cwd, byte[] scheme, byte[] path, int begin, int end, Encoding enc, int sub, int flags, Dir.GlobFunc<Dir.GlobArgs> func, Dir.GlobArgs arg)
has_magicback to summary
private static Dir.GlobMagic has_magic(byte[] bytes, int begin, int end, int flags)
indexOfback to summary
private static int indexOf(byte[] bytes, int begin, int end, final byte ch)
isAbsolutePathback to summary
private static boolean isAbsolutePath(byte[] path, int begin, int length)
isAlphaback to summary
private static boolean isAlpha(byte b)
isdirsepback to summary
private static boolean isdirsep(int c)
isdirsepback to summary
private static boolean isdirsep(byte c)
isDoubleStarAndSlashback to summary
private static boolean isDoubleStarAndSlash(byte[] bytes, int pos)
isRootback to summary
private static boolean isRoot(byte[] base)
isSpecialFileback to summary
private static boolean isSpecialFile(String name)
nextSlashIndexback to summary
private static int nextSlashIndex(byte[] bytes, int start, int end)
prependSchemeback to summary
private static byte[] prependScheme(byte[] scheme, byte[] path, int begin, int end)
push_bracesback to summary
private static int push_braces(Ruby runtime, String cwd, List<ByteList> result, Dir.GlobPattern pattern, boolean sort)
push_globback to summary
public static List<ByteList> push_glob(Ruby runtime, String cwd, ByteList globByteList, int flags, boolean sort)
push_globsback to summary
private static int push_globs(Ruby runtime, String cwd, List<ByteList> ary, ByteList pattern, int flags, boolean sort)
rangeback to summary
public static int range(byte[] _pat, int pat, int pend, char test, int flags)

Deprecated

No replacement; not intended to be made public

Annotations
@Deprecated
rb_path_nextback to summary
private static int rb_path_next(byte[] _s, int s, int send)
remove_backslashesback to summary
private static int remove_backslashes(byte[] bytes, int index, int end)
org.jruby.util back to summary

private final Class Dir.DirGlobber

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public final ByteList

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

Constructor Detail

DirGlobberback to summary
pack-priv DirGlobber(ByteList link)
org.jruby.util back to summary

pack-priv Class Dir.FilenameMatch

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final boolean
pack-priv final int
pack-priv final boolean
pack-priv final boolean
pack-priv int
pack-priv final boolean
pack-priv int

Constructor Summary

AccessConstructor and Description
pack-priv
FilenameMatch(int pcur, int scur, int flags)

Method Summary

Modifier and TypeMethod and Description
public int
bracket(byte[] pbytes, int p, int pend, byte[] sbytes, int s, int send, Encoding enc)

pack-priv int
helper(byte[] pbytes, int pend, byte[] sbytes, int send, Encoding enc)

private boolean
isEnd(byte[] sbytes, int s, int send)

private int
unescape(byte[] bytes, int i)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

escapeback to summary
pack-priv final boolean escape
flagsback to summary
pack-priv final int flags
nocaseback to summary
pack-priv final boolean nocase
pathnameback to summary
pack-priv final boolean pathname
pcurback to summary
pack-priv int pcur
periodback to summary
pack-priv final boolean period
scurback to summary
pack-priv int scur

Constructor Detail

FilenameMatchback to summary
pack-priv FilenameMatch(int pcur, int scur, int flags)

Method Detail

bracketback to summary
public int bracket(byte[] pbytes, int p, int pend, byte[] sbytes, int s, int send, Encoding enc)
helperback to summary
pack-priv int helper(byte[] pbytes, int pend, byte[] sbytes, int send, Encoding enc)
isEndback to summary
private boolean isEnd(byte[] sbytes, int s, int send)
unescapeback to summary
private int unescape(byte[] bytes, int i)
org.jruby.util back to summary

private Class Dir.GlobArgs

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final List<ByteList>
private int
c

pack-priv final Dir.GlobFunc<List<ByteList>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argback to summary
pack-priv final List<ByteList> arg
cback to summary
private int c
funcback to summary
pack-priv final Dir.GlobFunc<List<ByteList>> func

Constructor Detail

GlobArgsback to summary
pack-priv GlobArgs(Dir.GlobFunc<List<ByteList>> func, List<ByteList> arg)
org.jruby.util back to summary

private Interface Dir.GlobFunc<T>


Method Summary

Modifier and TypeMethod and Description
public int
call(byte[] ptr, int p, int len, Encoding enc, T ary)

Method Detail

callback to summary
public int call(byte[] ptr, int p, int len, Encoding enc, T ary)
org.jruby.util back to summary

pack-priv final Enum Dir.GlobMagic

extends Enum<Dir.GlobMagic>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Dir.GlobMagic
public static final Dir.GlobMagic
public static final Dir.GlobMagic

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Dir.GlobMagic
public static Dir.GlobMagic[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALPHAback to summary
public static final Dir.GlobMagic ALPHA
MAGICALback to summary
public static final Dir.GlobMagic MAGICAL
PLAINback to summary
public static final Dir.GlobMagic PLAIN

Constructor Detail

GlobMagicback to summary
private GlobMagic()

Method Detail

valueOfback to summary
public static Dir.GlobMagic valueOf(String name)
valuesback to summary
public static Dir.GlobMagic[] values()
org.jruby.util back to summary

private Class Dir.GlobPattern

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final byte[]
pack-priv final Encoding
pack-priv final int
private final int
private int

Constructor Summary

AccessConstructor and Description
pack-priv
GlobPattern(ByteList bytes, int flags)

pack-priv
GlobPattern(byte[] bytes, int index, int end, Encoding enc, int flags)

Method Summary

Modifier and TypeMethod and Description
public int
findClosingIndexOf(int leftTokenIndex)

public boolean
public int
public int
indexOf(byte c)

public byte
next()

public void
public void
setIndex(int value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beginback to summary
pack-priv final int begin
bytesback to summary
pack-priv final byte[] bytes
encback to summary
pack-priv final Encoding enc
endback to summary
pack-priv final int end
flagsback to summary
private final int flags
indexback to summary
private int index

Constructor Detail

GlobPatternback to summary
pack-priv GlobPattern(ByteList bytes, int flags)
GlobPatternback to summary
pack-priv GlobPattern(byte[] bytes, int index, int end, Encoding enc, int flags)

Method Detail

findClosingIndexOfback to summary
public int findClosingIndexOf(int leftTokenIndex)
hasNextback to summary
public boolean hasNext()
indexback to summary
public int index()
indexOfback to summary
public int indexOf(byte c)
nextback to summary
public byte next()
resetback to summary
public void reset()
setIndexback to summary
public void setIndex(int value)