public class RubyDir extends RubyObject implements java.io.Closeable
RubyObject.Data
RubyBasicObject.Finalizer
Modifier and Type | Field and Description |
---|---|
protected FileResource |
dir |
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, UNTRUST_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStamp
NULL_ARRAY
Modifier and Type | Method and Description |
---|---|
static IRubyObject |
aref(ThreadContext context,
IRubyObject recv,
IRubyObject[] args) |
static IRubyObject |
chdir(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
Changes the current directory to
path |
static RubyArray |
children(ThreadContext context,
IRubyObject recv,
IRubyObject arg)
Returns an array containing all of the filenames except for "." and ".." in the given directory.
|
static RubyArray |
children(ThreadContext context,
IRubyObject recv,
IRubyObject arg,
IRubyObject opts) |
static IRubyObject |
chroot(IRubyObject recv,
IRubyObject path)
Changes the root directory (only allowed by super user).
|
void |
close() |
IRubyObject |
close(ThreadContext context)
Closes the directory stream.
|
static RubyClass |
createDirClass(Ruby runtime) |
IRubyObject |
each_child(ThreadContext context,
Block block)
Executes the block once for each child in the directory
(i.e.
|
IRubyObject |
each_child(ThreadContext context,
org.jcodings.Encoding enc,
Block block)
Executes the block once for each child in the directory
(i.e.
|
static IRubyObject |
each_child(ThreadContext context,
IRubyObject recv,
IRubyObject arg,
Block block)
Executes the block once for each entry in the directory except
for "." and "..", passing the filename of each entry as parameter
to the block.
|
static IRubyObject |
each_child(ThreadContext context,
IRubyObject recv,
IRubyObject arg,
IRubyObject enc,
Block block)
Executes the block once for each entry in the directory except
for "." and "..", passing the filename of each entry as parameter
to the block.
|
IRubyObject |
each(ThreadContext context,
Block block)
Executes the block once for each entry in the directory.
|
IRubyObject |
each(ThreadContext context,
org.jcodings.Encoding enc,
Block block)
Executes the block once for each entry in the directory.
|
IRubyObject |
each(ThreadContext context,
IRubyObject encoding,
Block block) |
IRubyObject |
each19(ThreadContext context,
Block block)
Deprecated.
|
IRubyObject |
each19(ThreadContext context,
IRubyObject encoding,
Block block)
Deprecated.
|
static IRubyObject |
empty_p(ThreadContext context,
IRubyObject recv,
IRubyObject arg) |
RubyArray |
entries() |
static RubyArray |
entries(IRubyObject recv,
IRubyObject path)
Deprecated.
|
static RubyArray |
entries(IRubyObject recv,
IRubyObject path,
IRubyObject arg,
IRubyObject opts)
Deprecated.
|
static RubyArray |
entries(ThreadContext context,
IRubyObject recv,
IRubyObject arg)
Returns an array containing all of the filenames in the given directory.
|
static RubyArray |
entries(ThreadContext context,
IRubyObject recv,
IRubyObject arg,
IRubyObject opts) |
static RubyArray |
entries19(ThreadContext context,
IRubyObject recv,
IRubyObject arg)
Deprecated.
|
static RubyArray |
entries19(ThreadContext context,
IRubyObject recv,
IRubyObject arg,
IRubyObject opts)
Deprecated.
|
static IRubyObject |
exist(ThreadContext context,
IRubyObject recv,
IRubyObject arg) |
static IRubyObject |
exists_p(ThreadContext context,
IRubyObject recv,
IRubyObject arg) |
IRubyObject |
fileno(ThreadContext context) |
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 |
foreach(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject enc,
Block block) |
static IRubyObject |
foreach19(ThreadContext context,
IRubyObject recv,
IRubyObject path,
Block block)
Deprecated.
|
static IRubyObject |
foreach19(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject enc,
Block block)
Deprecated.
|
protected static java.util.List<java.lang.String> |
getContents(FileResource directory)
Deprecated.
no longer used
|
protected static java.util.List<RubyString> |
getContents(FileResource directory,
Ruby runtime)
Deprecated.
no longer used
|
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.
|
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. |
java.lang.String |
getPath() |
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 . |
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(ThreadContext context,
IRubyObject arg)
Creates a new
Dir . |
IRubyObject |
initialize19(ThreadContext context,
IRubyObject arg)
Deprecated.
|
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)
Deprecated.
|
static IRubyObject |
mkdir(ThreadContext context,
IRubyObject recv,
IRubyObject... args)
Creates the directory specified by
path . |
static IRubyObject |
mkdir19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
Deprecated.
|
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)
Deprecated.
|
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) |
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) |
<T> T |
toJava(java.lang.Class<T> target)
Convert the object to the specified Java class, if possible.
|
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, dig, eqlInternal, equalInternal, equals, getNativeClassIndex, hashCode, inspect, op_eqq, puts, specificEval, toRubyString, toString
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, 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, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id, infectBy, initialize_copy, initialize, 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, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing, method_missing19, method, method19, methods, methods, methods19, nil_p, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, 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, rbClone, rbInspect, 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_added, singleton_method_added19, singleton_method_removed, singleton_method_removed19, singleton_method_undefined, singleton_method_undefined19, singleton_method, singleton_methods, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
array
protected FileResource dir
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(ThreadContext context, IRubyObject arg)
public static IRubyObject aref(ThreadContext context, IRubyObject recv, IRubyObject[] args)
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()
@Deprecated public static RubyArray entries(IRubyObject recv, IRubyObject path)
@Deprecated public static RubyArray entries(IRubyObject recv, IRubyObject path, IRubyObject arg, IRubyObject opts)
public static RubyArray entries(ThreadContext context, IRubyObject recv, IRubyObject arg)
public static RubyArray entries(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject opts)
public static IRubyObject chdir(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
path
public static IRubyObject chroot(IRubyObject recv, IRubyObject path)
public static RubyArray children(ThreadContext context, IRubyObject recv, IRubyObject arg)
public static RubyArray children(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject opts)
public static IRubyObject rmdir(IRubyObject recv, IRubyObject path)
path
. The directory must be empty.public static IRubyObject rmdir19(ThreadContext context, IRubyObject recv, IRubyObject path)
public static IRubyObject each_child(ThreadContext context, IRubyObject recv, IRubyObject arg, Block block)
public static IRubyObject each_child(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject enc, Block block)
public static IRubyObject foreach(ThreadContext context, IRubyObject recv, IRubyObject path, Block block)
path
.public static IRubyObject foreach(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject enc, Block block)
@Deprecated public static IRubyObject foreach19(ThreadContext context, IRubyObject recv, IRubyObject path, Block block)
@Deprecated public static IRubyObject foreach19(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject enc, Block block)
public static RubyString getwd(IRubyObject recv)
public static IRubyObject home(ThreadContext context, IRubyObject recv, IRubyObject[] args)
public static IRubyObject mkdir(ThreadContext context, IRubyObject recv, IRubyObject... args)
path
. Note that the
mode
parameter is provided only to support existing Ruby
code, and is ignored.@Deprecated public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args)
@Deprecated public static IRubyObject mkdir19(ThreadContext context, IRubyObject recv, 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.@Deprecated public static IRubyObject open19(ThreadContext context, IRubyObject recv, IRubyObject path, Block block)
public IRubyObject close(ThreadContext context)
public final void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public IRubyObject each(ThreadContext context, org.jcodings.Encoding enc, Block block)
public IRubyObject each(ThreadContext context, Block block)
public IRubyObject each(ThreadContext context, IRubyObject encoding, Block block)
@Deprecated public IRubyObject each19(ThreadContext context, Block block)
@Deprecated public IRubyObject each19(ThreadContext context, IRubyObject encoding, Block block)
public IRubyObject each_child(ThreadContext context, org.jcodings.Encoding enc, Block block)
public IRubyObject each_child(ThreadContext context, Block block)
public IRubyObject inspect()
RubyBasicObject
to_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 IRubyObject
inspect
in class RubyBasicObject
public 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 java.lang.String getPath()
public IRubyObject read()
public IRubyObject rewind()
public static IRubyObject empty_p(ThreadContext context, IRubyObject recv, IRubyObject arg)
public static IRubyObject exist(ThreadContext context, IRubyObject recv, IRubyObject arg)
public static IRubyObject exists_p(ThreadContext context, IRubyObject recv, IRubyObject arg)
public IRubyObject fileno(ThreadContext context)
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.protected static JRubyFile getDirForRmdir(Ruby runtime, java.lang.String path)
runtime
- path
- protected static java.util.List<java.lang.String> getContents(FileResource directory)
protected static java.util.List<RubyString> getContents(FileResource directory, Ruby runtime)
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)
public <T> T toJava(java.lang.Class<T> target)
IRubyObject
toJava
in interface IRubyObject
toJava
in class RubyBasicObject
target
- The target type to which the object should be converted.IRubyObject.toJava(java.lang.Class<T>)
@Deprecated public static RubyArray entries19(ThreadContext context, IRubyObject recv, IRubyObject arg)
@Deprecated public static RubyArray entries19(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject opts)
Copyright © 2001-2019 JRuby. All Rights Reserved.