public class RubyDir extends RubyObject
RubyObject.Data
RubyBasicObject.Finalizer
Modifier and Type | Field and Description |
---|---|
protected FileResource |
dir |
FIELD_ALLOCATED_CLASSES, FIELD_ALLOCATOR_SET, 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_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 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) |
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 |
each19(ThreadContext context,
Block block) |
IRubyObject |
each19(ThreadContext context,
IRubyObject encoding,
Block block) |
RubyArray |
entries() |
static RubyArray |
entries(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) |
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 |
foreach19(ThreadContext context,
IRubyObject recv,
IRubyObject arg,
Block block) |
static IRubyObject |
foreach19(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject enc,
Block block) |
protected static List<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 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. |
protected static FileResource |
getDir(Ruby runtime,
String path,
boolean mustExist)
Returns a Java
File object for the specified path. |
protected static JRubyFile |
getDirForRmdir(Ruby runtime,
String path)
Similar to getDir, but performs different checks to match rmdir behavior.
|
static RubyString |
getHomeDirectoryPath(ThreadContext context) |
static IRubyObject |
getHomeDirectoryPath(ThreadContext context,
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 . |
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) |
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) |
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) |
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) |
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, dig, eqlInternal, equalInternal, equals, getNativeClassIndex, hashCode, inspect, op_eqq, puts, specificEval, toString
addFinalizer, anyToString, asJavaString, asString, 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, 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, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id, infectBy, initialize_copy, initialize, 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, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, 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, 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_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, 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, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
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.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()
public static RubyArray entries(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)
public static IRubyObject chdir(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
path
public 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)
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)
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(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)
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, org.jcodings.Encoding enc, Block block)
public IRubyObject each(ThreadContext context, Block block)
public IRubyObject each19(ThreadContext context, Block block)
public IRubyObject each19(ThreadContext context, IRubyObject encoding, 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 IRubyObject read()
public IRubyObject rewind()
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, 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, String path)
runtime
- path
- protected static List<String> getContents(FileResource directory)
directory
as an
ArrayList
containing the names of the files as Java Strings.protected static 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, 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)
Copyright © 2001-2016 JRuby. All Rights Reserved.