public class RubyDir extends RubyObject
RubyObject.DataRubyBasicObject.Finalizer| Modifier and Type | Field and Description |
|---|---|
protected FileResource |
dir |
private static ObjectAllocator |
DIR_ALLOCATOR |
private boolean |
isOpen |
private long |
lastModified |
private static java.lang.String[] |
NO_FILES |
private RubyString |
path |
private int |
pos |
private static java.util.regex.Pattern |
PROTOCOL_PATTERN |
private java.lang.String[] |
snapshot |
private static org.jcodings.Encoding |
UTF8 |
FIELD_ALLOCATED_CLASSES, FIELD_ALLOCATORS, IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, OBJECT_VAR0_ALLOCATOR, OBJECT_VAR1_ALLOCATOR, OBJECT_VAR2_ALLOCATOR, OBJECT_VAR3_ALLOCATOR, OBJECT_VAR4_ALLOCATOR, OBJECT_VAR5_ALLOCATOR, OBJECT_VAR6_ALLOCATOR, OBJECT_VAR7_ALLOCATOR, OBJECT_VAR8_ALLOCATOR, OBJECT_VAR9_ALLOCATOR, REIFYING_OBJECT_ALLOCATORALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, STAMP_OFFSET, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, VAR_TABLE_OFFSET, varTable, varTableStampNULL_ARRAY| Modifier and Type | Method and Description |
|---|---|
static IRubyObject |
aref(ThreadContext context,
IRubyObject recv,
IRubyObject[] args) |
private static RubyArray |
asRubyStringList(Ruby runtime,
java.util.List<org.jruby.util.ByteList> dirs) |
static IRubyObject |
chdir(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
Changes the current directory to
path |
private void |
checkDir() |
private static void |
checkDirIsTwoSlashesOnWindows(Ruby runtime,
java.lang.String path) |
static IRubyObject |
chroot(IRubyObject recv,
IRubyObject path)
Changes the root directory (only allowed by super user).
|
IRubyObject |
close()
Closes the directory stream.
|
static RubyClass |
createDirClass(Ruby runtime) |
private static java.lang.String |
dirFromPath(java.lang.String path,
Ruby runtime) |
private static java.util.ArrayList<org.jruby.util.ByteList> |
dirGlobs(ThreadContext context,
java.lang.String cwd,
IRubyObject[] args,
int flags) |
IRubyObject |
each(ThreadContext context,
Block block)
Executes the block once for each entry in the directory.
|
IRubyObject |
each19(ThreadContext context,
Block block) |
RubyArray |
entries() |
static RubyArray |
entries(ThreadContext context,
IRubyObject recv,
IRubyObject path)
Returns an array containing all of the filenames in the given directory.
|
static RubyArray |
entries19(ThreadContext context,
IRubyObject recv,
IRubyObject arg) |
static RubyArray |
entries19(ThreadContext context,
IRubyObject recv,
IRubyObject arg,
IRubyObject opts) |
private static RubyArray |
entriesCommon(ThreadContext context,
java.lang.String path) |
static IRubyObject |
exist(ThreadContext context,
IRubyObject recv,
IRubyObject arg) |
static IRubyObject |
foreach(ThreadContext context,
IRubyObject recv,
IRubyObject _path,
Block block)
Executes the block once for each file in the directory specified by
path. |
static IRubyObject |
foreach19(ThreadContext context,
IRubyObject recv,
IRubyObject arg,
Block block) |
private static IRubyObject |
foreachCommon(ThreadContext context,
IRubyObject recv,
Ruby runtime,
RubyString _path,
Block block) |
protected static java.util.List<java.lang.String> |
getContents(FileResource directory)
Returns the contents of the specified
directory as an
ArrayList containing the names of the files as Java Strings. |
protected static java.util.List<RubyString> |
getContents(FileResource directory,
Ruby runtime)
Returns the contents of the specified
directory as an
ArrayList containing the names of the files as Ruby Strings. |
private static java.lang.String |
getCWD(Ruby runtime) |
protected static FileResource |
getDir(Ruby runtime,
java.lang.String path,
boolean mustExist)
Returns a Java
File object for the specified path. |
protected static JRubyFile |
getDirForRmdir(Ruby runtime,
java.lang.String path)
Similar to getDir, but performs different checks to match rmdir behavior.
|
private static java.lang.String[] |
getEntries(ThreadContext context,
FileResource dir,
java.lang.String path) |
static RubyString |
getHomeDirectoryPath(ThreadContext context) |
static IRubyObject |
getHomeDirectoryPath(ThreadContext context,
java.lang.String user)
Returns the home directory of the specified
user on the
system. |
static RubyString |
getwd(IRubyObject recv)
Returns the current directory.
|
static IRubyObject |
glob(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
Returns an array of filenames matching the specified wildcard pattern
pat. |
private static org.jruby.util.ByteList |
globArgumentAsByteList(ThreadContext context,
IRubyObject arg) |
static IRubyObject |
home(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
Returns the home directory of the current user or the named user if given.
|
IRubyObject |
initialize(IRubyObject arg)
Deprecated.
|
IRubyObject |
initialize(ThreadContext context,
IRubyObject arg)
Creates a new
Dir. |
IRubyObject |
initialize19(IRubyObject arg)
Deprecated.
|
IRubyObject |
initialize19(ThreadContext context,
IRubyObject arg) |
IRubyObject |
inspect()
rb_obj_inspect
call-seq:
obj.inspect => string
Returns a string containing a human-readable representation of
obj.
|
static IRubyObject |
mkdir(IRubyObject recv,
IRubyObject[] args)
Creates the directory specified by
path. |
static IRubyObject |
mkdir19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args) |
private static IRubyObject |
mkdirCommon(Ruby runtime,
java.lang.String path,
IRubyObject[] args) |
static IRubyObject |
open(ThreadContext context,
IRubyObject recv,
IRubyObject path,
Block block)
Returns a new directory object for
path. |
static IRubyObject |
open19(ThreadContext context,
IRubyObject recv,
IRubyObject path,
Block block) |
IRubyObject |
path(ThreadContext context) |
IRubyObject |
read()
Returns the next entry from this directory.
|
IRubyObject |
rewind()
Moves position in this directory to the first entry.
|
static IRubyObject |
rmdir(IRubyObject recv,
IRubyObject path)
Deletes the directory specified by
path. |
static IRubyObject |
rmdir19(ThreadContext context,
IRubyObject recv,
IRubyObject path) |
private static IRubyObject |
rmdirCommon(Ruby runtime,
java.lang.String path) |
IRubyObject |
seek(IRubyObject newPos)
Moves to a position
d. |
IRubyObject |
set_pos(IRubyObject newPos) |
RubyInteger |
tell()
Returns the current position in the directory.
|
IRubyObject |
to_path(ThreadContext context) |
private void |
update() |
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, equals, getNativeTypeIndex, hashCode, initialize, initialize, inspect, op_eqq, puts, specificEval, toStringaddFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getNativeHandle, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, infectBy, infectBy, initialize_copy, initialize19, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, op_cmp, op_equal_19, op_equal, op_match, op_match19, op_not_equal, op_not_match, op_not, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, recacheBuiltinMethods, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, singleton_methods19, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, toJava, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnderprivate RubyString path
protected FileResource dir
private long lastModified
private java.lang.String[] snapshot
private int pos
private boolean isOpen
private static final org.jcodings.Encoding UTF8
private static java.util.regex.Pattern PROTOCOL_PATTERN
private static final ObjectAllocator DIR_ALLOCATOR
private static final java.lang.String[] NO_FILES
private final void checkDir()
private void update()
@Deprecated public IRubyObject initialize(IRubyObject arg)
public IRubyObject initialize(ThreadContext context, IRubyObject arg)
Dir. This method takes a snapshot of the
contents of the directory at creation time, so changes to the contents
of the directory will not be reflected during the lifetime of the
Dir object returned, so a new Dir instance
must be created to reflect changes to the underlying file system.@Deprecated public IRubyObject initialize19(IRubyObject arg)
public IRubyObject initialize19(ThreadContext context, IRubyObject arg)
private static java.util.ArrayList<org.jruby.util.ByteList> dirGlobs(ThreadContext context, java.lang.String cwd, IRubyObject[] args, int flags)
private static RubyArray asRubyStringList(Ruby runtime, java.util.List<org.jruby.util.ByteList> dirs)
private static java.lang.String getCWD(Ruby runtime)
public static IRubyObject aref(ThreadContext context, IRubyObject recv, IRubyObject[] args)
private static org.jruby.util.ByteList globArgumentAsByteList(ThreadContext context, IRubyObject arg)
public static IRubyObject glob(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
pat. If a block is given, the array is iterated internally
with each filename is passed to the block in turn. In this case, Nil is
returned.public RubyArray entries()
public static RubyArray entries(ThreadContext context, IRubyObject recv, IRubyObject path)
public static RubyArray entries19(ThreadContext context, IRubyObject recv, IRubyObject arg)
public static RubyArray entries19(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject opts)
private static RubyArray entriesCommon(ThreadContext context, java.lang.String path)
private static java.lang.String[] getEntries(ThreadContext context, FileResource dir, java.lang.String path)
private static void checkDirIsTwoSlashesOnWindows(Ruby runtime, java.lang.String path)
public static IRubyObject chdir(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
pathpublic static IRubyObject chroot(IRubyObject recv, IRubyObject path)
public static IRubyObject rmdir(IRubyObject recv, IRubyObject path)
path. The directory must
be empty.public static IRubyObject rmdir19(ThreadContext context, IRubyObject recv, IRubyObject path)
private static IRubyObject rmdirCommon(Ruby runtime, java.lang.String path)
public static IRubyObject foreach(ThreadContext context, IRubyObject recv, IRubyObject _path, Block block)
path.public static IRubyObject foreach19(ThreadContext context, IRubyObject recv, IRubyObject arg, Block block)
private static IRubyObject foreachCommon(ThreadContext context, IRubyObject recv, Ruby runtime, RubyString _path, Block block)
public static RubyString getwd(IRubyObject recv)
public static IRubyObject home(ThreadContext context, IRubyObject recv, IRubyObject[] args)
public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args)
path. Note that the
mode parameter is provided only to support existing Ruby
code, and is ignored.public static IRubyObject mkdir19(ThreadContext context, IRubyObject recv, IRubyObject[] args)
private static IRubyObject mkdirCommon(Ruby runtime, java.lang.String path, IRubyObject[] args)
public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject path, Block block)
path. If a block is
provided, a new directory object is passed to the block, which closes the
directory object before terminating.public static IRubyObject open19(ThreadContext context, IRubyObject recv, IRubyObject path, Block block)
public IRubyObject close()
public IRubyObject each(ThreadContext context, Block block)
public IRubyObject each19(ThreadContext context, Block block)
public IRubyObject inspect()
RubyBasicObjectto_s method to
generate the string.
[ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"inspect in interface IRubyObjectinspect in class RubyBasicObjectpublic RubyInteger tell()
public IRubyObject seek(IRubyObject newPos)
d. pos must be a value
returned by tell or 0.public IRubyObject set_pos(IRubyObject newPos)
public IRubyObject path(ThreadContext context)
public IRubyObject to_path(ThreadContext context)
public IRubyObject read()
public IRubyObject rewind()
public static IRubyObject exist(ThreadContext context, IRubyObject recv, IRubyObject arg)
protected static FileResource getDir(Ruby runtime, java.lang.String path, boolean mustExist)
File object for the specified path. If
path is not a directory, throws IOError.path - path for which to return the File object.mustExist - is true the directory must exist. If false it must not.java.io.IOError - if path is not a directory.protected static JRubyFile getDirForRmdir(Ruby runtime, java.lang.String path)
runtime - path - private static java.lang.String dirFromPath(java.lang.String path,
Ruby runtime)
throws RaiseException
RaiseExceptionprotected static java.util.List<java.lang.String> getContents(FileResource directory)
directory as an
ArrayList containing the names of the files as Java Strings.protected static java.util.List<RubyString> getContents(FileResource directory, Ruby runtime)
directory as an
ArrayList containing the names of the files as Ruby Strings.public static IRubyObject getHomeDirectoryPath(ThreadContext context, java.lang.String user)
user on the
system. If the home directory of the specified user cannot be found,
an ArgumentError it thrown.public static RubyString getHomeDirectoryPath(ThreadContext context)