Top Description Inners Fields Constructors Methods
org.jruby

public Class RubyDir

extends RubyObject
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Annotations
@JRubyClass
name:Dir
include:Enumerable
Imports
java.io.Closeable, .File, .FileInputStream, .IOException, java.nio.file.FileSystems, .Path, .Watchable, java.util.ArrayList, .Arrays, .Collections, .List, .Optional, jnr.posix.FileStat, .POSIX, .Passwd, jnr.posix.util.Platform, org.jcodings.Encoding, org.jcodings.specific.USASCIIEncoding, org.jruby.anno.JRubyMethod, .JRubyClass, org.jruby.api.Create, org.jruby.exceptions.RaiseException, org.jruby.runtime.Arity, .Block, .ClassIndex, .ThreadContext, org.jruby.runtime.backtrace.RubyStackTraceElement, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.*, org.jruby.ast.util.ArgsUtil

The Ruby built-in class Dir.
Author
jvoegele

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final String[]
private static final String[]
protected FileResource
private Encoding
pack-priv static final ByteList
private boolean
private long
private static final String[]
private RubyString
private int
private String[]
private static final ByteList
Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

AccessConstructor and Description
public
RubyDir(Ruby runtime, RubyClass type)

Method Summary

Modifier and TypeMethod and Description
public static IRubyObject
aref(ThreadContext context, IRubyObject recv, IRubyObject[] args)

private static RubyArray<T extends IRubyObject>
public static IRubyObject
chdir(ThreadContext context, IRubyObject recv, IRubyObject path, Block block)

Changes the current directory to path

public static IRubyObject
chdir(ThreadContext context, IRubyObject recv, Block block)

Changes the current directory to path

public IRubyObject
chdir(ThreadContext context, Block block)

public static IRubyObject
chdir(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
Deprecated

private static IRubyObject
chdirCommon(ThreadContext context, Block block, RubyString path, boolean yieldPath)

private void
private void
private static void
public RubyArray<T extends IRubyObject>
children(ThreadContext context)

Returns an array containing all of the filenames except for "." and ".." in the given directory.

public static RubyArray<T extends IRubyObject>
public static RubyArray<T extends IRubyObject>
public static IRubyObject
chroot(IRubyObject recv, IRubyObject path)
Deprecated since 10.0.

public static IRubyObject
chroot(ThreadContext context, IRubyObject recv, IRubyObject path)

Changes the root directory (only allowed by super user).

public IRubyObject
close(ThreadContext context)

Closes the directory stream.

public final void
close()

Implements java.io.Closeable.close.

Deprecated since 10.0.

Closes this stream and releases any system resources associated with it.

public static RubyClass
createDirClass(ThreadContext context, RubyClass Object, RubyModule Enumerable)

private static String
dirFromPath(final String path, final Ruby runtime)

private static ArrayList<ByteList>
dirGlobs(ThreadContext context, String cwd, IRubyObject[] args, int flags, boolean sort)

public IRubyObject
each(ThreadContext context, Encoding enc, Block block)

Executes the block once for each entry in the directory.

public IRubyObject
each(ThreadContext context, Block block)

Executes the block once for each entry in the directory.

public IRubyObject
each(ThreadContext context, IRubyObject encOpts, Block block)

public 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.

public static IRubyObject
each_child(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject encOpts, 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.

public IRubyObject
each_child(ThreadContext context, Encoding enc, Block block)

Executes the block once for each child in the directory (i.e. all the directory entries except for "." and "..").

public IRubyObject
each_child(ThreadContext context, Block block)

Executes the block once for each child in the directory (i.e. all the directory entries except for "." and "..").

private static IRubyObject
public static IRubyObject
public RubyArray<T extends IRubyObject>
entries()
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>

Returns:

all entries for this Dir
entries
(ThreadContext context)

public static RubyArray<T extends IRubyObject>
entries(ThreadContext context, IRubyObject recv, IRubyObject arg)

Returns an array containing all of the filenames in the given directory.

public static RubyArray<T extends IRubyObject>
public static RubyArray<T extends IRubyObject>
entries(IRubyObject recv, IRubyObject path)
Deprecated

public static RubyArray<T extends IRubyObject>
entries(IRubyObject recv, IRubyObject path, IRubyObject arg, IRubyObject opts)
Deprecated

private static RubyArray<T extends IRubyObject>
entriesCommon(ThreadContext context, IRubyObject path, Encoding encoding, final boolean childrenOnly)

public static IRubyObject
public static IRubyObject
exists_p(ThreadContext context, IRubyObject recv, IRubyObject arg)
Deprecated since 10.0.

public static IRubyObject
fchdir(ThreadContext context, IRubyObject dirClass, IRubyObject ignored)

public IRubyObject
public static IRubyObject
for_fd(ThreadContext context, IRubyObject recv, IRubyObject ignored)

public static IRubyObject
foreach(ThreadContext context, IRubyObject recv, IRubyObject path, Block block)

Executes the block once for each file in the directory specified by path.

public static IRubyObject
foreach(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject encOpts, Block block)

private static IRubyObject
foreachCommon(ThreadContext context, IRubyObject recv, RubyString path, IRubyObject encOpts, Block block)

protected static List<String>
getContents(FileResource directory)
Deprecated since 9.4-. no longer used

protected static List<RubyString>
getContents(FileResource directory, Ruby runtime)
Deprecated since 9.4-. no longer used

private static String
getCWD(Ruby runtime)

protected static FileResource
getDir(final Ruby runtime, final String
path for which to return the File object.
path
,
final boolean
is true the directory must exist. If false it must not.
mustExist
)

Returns a Java File object for the specified path.

protected static JRubyFile
getDirForRmdir(final Ruby runtime, final String path)

Similar to getDir, but performs different checks to match rmdir behavior.

private static Encoding
private static String[]
private static FileResource
getExistingDir(final Ruby runtime, final String path)

public static IRubyObject
getHomeDirectoryPath(ThreadContext context, String user)

Returns the home directory of the specified user on the system.

public static RubyString
pack-priv static RubyString
public static Optional<String>
public String
public static RubyString
getwd(IRubyObject recv)
Deprecated since 10.0.

public static RubyString
getwd(ThreadContext context, IRubyObject recv)

Returns the current directory.

public static IRubyObject
glob(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)

Returns an array of filenames matching the specified wildcard pattern pat.

private static ByteList
private static void
globOptions(ThreadContext context, IRubyObject[] args, String[] keys, RubyDir.GlobOptions options)

public static IRubyObject
home(ThreadContext context, IRubyObject recv)

Returns the home directory of the current user or the named user if given.

public static IRubyObject
public static IRubyObject
home(ThreadContext context, IRubyObject recv, IRubyObject[] args)
Deprecated

public IRubyObject

Returns:

a new Dir object
initialize
(ThreadContext
current context
context
,
IRubyObject
target path
path
)

Creates a new Dir.

public IRubyObject

Returns:

a new Dir object
initialize
(ThreadContext
current context
context
,
IRubyObject
target path
path
,
IRubyObject
encoding options
encOpts
)

Like initialize(ThreadContext, IRubyObject) but accepts an :encoding option.

private RubyDir
public IRubyObject
inspect(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

Returns a string containing a human-readable representation of obj.

private static String[]
list(FileResource directory)

public static IRubyObject
mkdir(ThreadContext context, IRubyObject recv, IRubyObject... args)

Creates the directory specified by path.

public static IRubyObject
mkdir(IRubyObject recv, IRubyObject[] args)
Deprecated

private static IRubyObject
private static RubyArray<T extends IRubyObject>
newEntryArray(ThreadContext context, String[] files, Encoding encoding, boolean childrenOnly)

private static RubyString
public static IRubyObject
open(ThreadContext context, IRubyObject recv, IRubyObject path, Block block)

Returns a new directory object for path.

public static IRubyObject
open(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject encOpts, Block block)

public IRubyObject
public IRubyObject
public IRubyObject
read()
Deprecated since 10.0.

public IRubyObject
read(ThreadContext context)

Returns the next entry from this directory.

public IRubyObject
rewind()
Deprecated since 10.0.

public IRubyObject
rewind(ThreadContext context)

Moves position in this directory to the first entry.

public static IRubyObject
rmdir(IRubyObject recv, IRubyObject path)
Deprecated since 10.0.

public static IRubyObject
rmdir(ThreadContext context, IRubyObject recv, IRubyObject path)

Deletes the directory specified by path.

public static IRubyObject
rmdir19(IRubyObject recv, IRubyObject path)
Deprecated

private static RubyFixnum
public IRubyObject
seek(IRubyObject newPos)
Deprecated since 10.0.

public IRubyObject
seek(ThreadContext context, IRubyObject newPos)

Moves to a position d.

public IRubyObject
set_pos(IRubyObject newPos)
Deprecated since 10.0.

public IRubyObject
public RubyInteger
tell(ThreadContext context)

Returns the current position in the directory.

public RubyInteger
tell()
Deprecated

public IRubyObject
public <T> T
toJava(Class<T>
The target type to which the object should be converted.
target
)

Overrides org.jruby.RubyBasicObject.toJava.

Implements org.jruby.runtime.builtin.IRubyObject.toJava.

Convert the object to the specified Java class, if possible.

Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalequalsfinishObjectClassgetNativeClassIndexhashCodeinspectop_eqqputsspecificEvaltoRubyStringtoString