org.jruby
Class RubyFile

java.lang.Object
  extended by org.jruby.RubyBasicObject
      extended by org.jruby.RubyObject
          extended by org.jruby.RubyIO
              extended by org.jruby.RubyFile
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<IRubyObject>, InstanceVariables, InternalVariables, IRubyObject, EncodingCapable, CoreObjectType
Direct Known Subclasses:
RubyTempfile

public class RubyFile
extends RubyIO
implements EncodingCapable

Ruby File class equivalent in java.

See Also:
Serialized Form

Nested Class Summary
static class RubyFile.Constants
           
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Data
 
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer
 
Field Summary
static int LOCK_EX
           
static int LOCK_NB
           
static int LOCK_SH
           
static int LOCK_UN
           
protected  java.lang.String path
           
 
Fields inherited from class org.jruby.RubyIO
blockingThreads, externalEncoding, internalEncoding, openFile
 
Fields inherited from class org.jruby.RubyObject
OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
 
Fields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
RubyFile(Ruby runtime, RubyClass type)
           
RubyFile(Ruby runtime, java.lang.String path, java.io.InputStream in)
           
RubyFile(Ruby runtime, java.lang.String path, java.io.Reader reader)
           
 
Method Summary
static IRubyObject absolute_path(ThreadContext context, IRubyObject recv, IRubyObject[] args)
          ---------------------------------------------------- File::absolute_path File.absolute_path(file_name [, dir_string] ) -> abs_file_name From Ruby 1.9.1 ------------------------------------------------------------------------ Converts a pathname to an absolute pathname.
 IRubyObject atime(ThreadContext context)
           
static IRubyObject atime(ThreadContext context, IRubyObject recv, IRubyObject filename)
           
static IRubyObject basename(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
static java.lang.String canonicalize(java.lang.String path)
           
 IRubyObject chmod(ThreadContext context, IRubyObject arg)
           
static IRubyObject chmod(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
 IRubyObject chown(ThreadContext context, IRubyObject arg1, IRubyObject arg2)
           
static IRubyObject chown(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
 IRubyObject close()
          Closes all open resources for the IO.
static RubyClass createFileClass(Ruby runtime)
           
 IRubyObject ctime(ThreadContext context)
           
static IRubyObject ctime(ThreadContext context, IRubyObject recv, IRubyObject filename)
           
static IRubyObject dirname(ThreadContext context, IRubyObject recv, IRubyObject arg)
           
static IRubyObject expand_path(ThreadContext context, IRubyObject recv, IRubyObject[] args)
          Converts a pathname to an absolute pathname.
static IRubyObject expand_path19(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
static java.lang.String expandUserPath(ThreadContext context, java.lang.String path)
          This method checks a path, and if it starts with ~, then it expands the path to the absolute path of the user's home directory.
static IRubyObject extname(ThreadContext context, IRubyObject recv, IRubyObject arg)
          Returns the extension name of the file.
static JRubyFile file(IRubyObject pathOrFile)
          Get the fully-qualified JRubyFile object for the path, taking into account the runtime's current directory.
 IRubyObject flock(ThreadContext context, IRubyObject lockingConstant)
           
static IRubyObject fnmatch(ThreadContext context, IRubyObject recv, IRubyObject[] args)
          Returns true if path matches against pattern The pattern is not a regular expression; instead it follows rules similar to shell filename globbing.
static IRubyObject ftype(ThreadContext context, IRubyObject recv, IRubyObject filename)
           
static RubyString get_path(ThreadContext context, IRubyObject obj)
          similar in spirit to rb_get_path from 1.9 source
static java.util.zip.ZipEntry getDirOrFileEntry(java.util.zip.ZipFile zf, java.lang.String path)
           
 org.jcodings.Encoding getEncoding()
           
static java.util.zip.ZipEntry getFileEntry(java.util.zip.ZipFile zf, java.lang.String path)
           
 java.lang.String getPath()
           
 IRubyObject initialize(IRubyObject[] args, Block block)
           
 IRubyObject initialize19(ThreadContext context, IRubyObject[] args, Block block)
           
 IRubyObject inspect()
          rb_obj_inspect call-seq: obj.inspect => string Returns a string containing a human-readable representation of obj.
static RubyString join(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
 IRubyObject lchmod(ThreadContext context, IRubyObject arg)
           
static IRubyObject lchmod(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
 IRubyObject lchown(ThreadContext context, IRubyObject arg1, IRubyObject arg2)
           
static IRubyObject lchown(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
static IRubyObject link(ThreadContext context, IRubyObject recv, IRubyObject from, IRubyObject to)
           
 IRubyObject lstat(ThreadContext context)
           
static IRubyObject lstat(ThreadContext context, IRubyObject recv, IRubyObject filename)
           
 IRubyObject mtime(ThreadContext context)
           
static IRubyObject mtime(ThreadContext context, IRubyObject recv, IRubyObject filename)
           
protected  void openInternal(java.lang.String path, java.lang.String modeString)
           
protected  void openInternal(java.lang.String path, java.lang.String modeString, ModeFlags modes)
           
 IRubyObject path(ThreadContext context)
           
static IRubyObject path(ThreadContext context, IRubyObject self, IRubyObject str)
           
static IRubyObject readlink(ThreadContext context, IRubyObject recv, IRubyObject path)
           
static IRubyObject realdirpath(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
static IRubyObject realpath(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
static IRubyObject rename(ThreadContext context, IRubyObject recv, IRubyObject oldName, IRubyObject newName)
           
 void setEncoding(org.jcodings.Encoding encoding)
           
 IRubyObject size(ThreadContext context)
           
static RubyArray split(ThreadContext context, IRubyObject recv, IRubyObject arg)
           
static java.lang.String[] splitURI(java.lang.String path)
           
 IRubyObject stat(ThreadContext context)
           
static IRubyObject stat(ThreadContext context, IRubyObject recv, IRubyObject filename)
           
static IRubyObject symlink(ThreadContext context, IRubyObject recv, IRubyObject from, IRubyObject to)
           
protected  void sysopenInternal(java.lang.String path, ModeFlags modes, int perm)
           
 java.lang.String toString()
          The default toString method is just a wrapper that calls the Ruby "to_s" method.
 IRubyObject truncate(ThreadContext context, IRubyObject arg)
           
static IRubyObject truncate(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2)
           
static IRubyObject truncate19(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2)
           
static IRubyObject umask(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
static IRubyObject unlink(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
static IRubyObject utime(ThreadContext context, IRubyObject recv, IRubyObject[] args)
           
 
Methods inherited from class org.jruby.RubyIO
addBlockingThread, autoclose_set, autoclose, binmode, binread, bytes, chars, close_read, close_write, close2, closed_p, codepoints, convertToIO, copy_stream, createIOClass, ctl, each_byte, each_byteInternal, each_char, each_charInternal, each_codepoint, each_line, each_lineInternal, each, emptyBufferOrEOF, eof_p, external_encoding, failIfDirectory, fcntl, fcntl, fdopen, fileno, flush, foreach, foreach19, foreachInternal, foreachInternal19, fsync, fwrite, getBlocking, getbyte19, getc, getc19, getcCommon, getChannel, getDescriptorByFileno, getHandler, getInStream, getIOModes, getIOModesIntFromString, getline, getline, getNativeTypeIndex, getNewFileno, getOpenFile, getOpenFileChecked, getOutStream, gets, gets, gets, gets19, gets19, gets19, initialize_copy, initialize19, initialize19, initialize19, internal_encoding, interruptBlockingThreads, ioctl, isAutoclose, isClosed, lineno_set, lineno, lines, lines19, newInstance, newIO, obliterateProcess, op_append, op_binmode, open, parseModes, parseModes19, parseOptions, pid, pipe, popen, popen19, popen3, popen4, popenSpecial, pos_set, pos, print, print, printf, putc, putc, puts, puts, read_nonblock, read, read, read, read, read, read, read, read, read19, readAll, readAll, readAllCommon, readchar, readchar19, readline, readline, readline, readlines, readlines, readpartial, readStatic, readStatic, readStatic, registerDescriptor, registerDescriptor, removeBlockingThread, reopen, reopenIO, reopenPath, restartSystemCall, rewind, seek, seek, seek, select_static, select, set_encoding, set_encoding, set_encoding, setAutoclose, swallow, sync_set, sync, sysopen, sysopen19, sysread, sysseek, syswrite, to_io, tryConvert, tty_p, ungetc, ungetc19, unregisterDescriptor, write_nonblock, write, write, write, writeDataBuffered
 
Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, equals, hashCode, initialize, op_eqq, puts, specificEval
 
Methods inherited from class org.jruby.RubyBasicObject
addFinalizer, 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, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize19, initialize19, initialize19, initialize19, initialize19, initObjectId, 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, 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, send19, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, 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, yieldUnder
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCK_SH

public static final int LOCK_SH
See Also:
Constant Field Values

LOCK_EX

public static final int LOCK_EX
See Also:
Constant Field Values

LOCK_NB

public static final int LOCK_NB
See Also:
Constant Field Values

LOCK_UN

public static final int LOCK_UN
See Also:
Constant Field Values

path

protected java.lang.String path
Constructor Detail

RubyFile

public RubyFile(Ruby runtime,
                RubyClass type)

RubyFile

public RubyFile(Ruby runtime,
                java.lang.String path,
                java.io.Reader reader)

RubyFile

public RubyFile(Ruby runtime,
                java.lang.String path,
                java.io.InputStream in)
Method Detail

getEncoding

public org.jcodings.Encoding getEncoding()
Specified by:
getEncoding in interface EncodingCapable

setEncoding

public void setEncoding(org.jcodings.Encoding encoding)
Specified by:
setEncoding in interface EncodingCapable

getPath

public java.lang.String getPath()

createFileClass

public static RubyClass createFileClass(Ruby runtime)

close

public IRubyObject close()
Description copied from class: RubyIO

Closes all open resources for the IO. It also removes it from our magical all open file descriptor pool.

Overrides:
close in class RubyIO
Returns:
The IO.

flock

public IRubyObject flock(ThreadContext context,
                         IRubyObject lockingConstant)

initialize

public IRubyObject initialize(IRubyObject[] args,
                              Block block)
Overrides:
initialize in class RubyIO

initialize19

public IRubyObject initialize19(ThreadContext context,
                                IRubyObject[] args,
                                Block block)

sysopenInternal

protected void sysopenInternal(java.lang.String path,
                               ModeFlags modes,
                               int perm)
                        throws InvalidValueException
Throws:
InvalidValueException

openInternal

protected void openInternal(java.lang.String path,
                            java.lang.String modeString,
                            ModeFlags modes)
                     throws InvalidValueException
Throws:
InvalidValueException

openInternal

protected void openInternal(java.lang.String path,
                            java.lang.String modeString)
                     throws InvalidValueException
Throws:
InvalidValueException

chmod

public IRubyObject chmod(ThreadContext context,
                         IRubyObject arg)

chown

public IRubyObject chown(ThreadContext context,
                         IRubyObject arg1,
                         IRubyObject arg2)

atime

public IRubyObject atime(ThreadContext context)

ctime

public IRubyObject ctime(ThreadContext context)

lchmod

public IRubyObject lchmod(ThreadContext context,
                          IRubyObject arg)

lchown

public IRubyObject lchown(ThreadContext context,
                          IRubyObject arg1,
                          IRubyObject arg2)

lstat

public IRubyObject lstat(ThreadContext context)

mtime

public IRubyObject mtime(ThreadContext context)

path

public static IRubyObject path(ThreadContext context,
                               IRubyObject self,
                               IRubyObject str)

get_path

public static RubyString get_path(ThreadContext context,
                                  IRubyObject obj)
similar in spirit to rb_get_path from 1.9 source

Parameters:
context -
obj -
Returns:

file

public static JRubyFile file(IRubyObject pathOrFile)
Get the fully-qualified JRubyFile object for the path, taking into account the runtime's current directory.


path

public IRubyObject path(ThreadContext context)

stat

public IRubyObject stat(ThreadContext context)
Overrides:
stat in class RubyIO

truncate

public IRubyObject truncate(ThreadContext context,
                            IRubyObject arg)

toString

public java.lang.String toString()
Description copied from class: RubyObject
The default toString method is just a wrapper that calls the Ruby "to_s" method.

Overrides:
toString in class RubyIO

inspect

public IRubyObject inspect()
Description copied from class: RubyBasicObject
rb_obj_inspect call-seq: obj.inspect => string Returns a string containing a human-readable representation of obj. If not overridden, uses the 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"

Specified by:
inspect in interface IRubyObject
Overrides:
inspect in class RubyBasicObject
Returns:
String

basename

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

chmod

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

chown

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

dirname

public static IRubyObject dirname(ThreadContext context,
                                  IRubyObject recv,
                                  IRubyObject arg)

extname

public static IRubyObject extname(ThreadContext context,
                                  IRubyObject recv,
                                  IRubyObject arg)
Returns the extension name of the file. An empty string is returned if the filename (not the entire path) starts or ends with a dot.

Parameters:
recv -
arg - Path to get extension name of
Returns:
Extension, including the dot, or an empty string

expand_path

public static IRubyObject expand_path(ThreadContext context,
                                      IRubyObject recv,
                                      IRubyObject[] args)
Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless a second argument is given, in which case it will be used as the starting point. If the second argument is also relative, it will first be converted to an absolute pathname.

Parameters:
recv -
args -
Returns:
Resulting absolute path as a String

expand_path19

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

absolute_path

public static IRubyObject absolute_path(ThreadContext context,
                                        IRubyObject recv,
                                        IRubyObject[] args)
---------------------------------------------------- File::absolute_path File.absolute_path(file_name [, dir_string] ) -> abs_file_name From Ruby 1.9.1 ------------------------------------------------------------------------ Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless _dir_string_ is given, in which case it will be used as the starting point. If the given pathname starts with a ``+~+'' it is NOT expanded, it is treated as a normal directory name. File.absolute_path("~oracle/bin") #=> "/~oracle/bin"

Parameters:
context -
recv -
args -
Returns:

realdirpath

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

realpath

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

splitURI

public static java.lang.String[] splitURI(java.lang.String path)

expandUserPath

public static java.lang.String expandUserPath(ThreadContext context,
                                              java.lang.String path)
This method checks a path, and if it starts with ~, then it expands the path to the absolute path of the user's home directory. If the string does not begin with ~, then the string is simply returned. unaltered.

Parameters:
recv -
path - Path to check
Returns:
Expanded path

canonicalize

public static java.lang.String canonicalize(java.lang.String path)

fnmatch

public static IRubyObject fnmatch(ThreadContext context,
                                  IRubyObject recv,
                                  IRubyObject[] args)
Returns true if path matches against pattern The pattern is not a regular expression; instead it follows rules similar to shell filename globbing. It may contain the following metacharacters: *: Glob - match any sequence chars (re: .*). If like begins with '.' then it doesn't. ?: Matches a single char (re: .). [set]: Matches a single char in a set (re: [...]).


ftype

public static IRubyObject ftype(ThreadContext context,
                                IRubyObject recv,
                                IRubyObject filename)

join

public static RubyString join(ThreadContext context,
                              IRubyObject recv,
                              IRubyObject[] args)

lstat

public static IRubyObject lstat(ThreadContext context,
                                IRubyObject recv,
                                IRubyObject filename)

stat

public static IRubyObject stat(ThreadContext context,
                               IRubyObject recv,
                               IRubyObject filename)

atime

public static IRubyObject atime(ThreadContext context,
                                IRubyObject recv,
                                IRubyObject filename)

ctime

public static IRubyObject ctime(ThreadContext context,
                                IRubyObject recv,
                                IRubyObject filename)

lchmod

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

lchown

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

link

public static IRubyObject link(ThreadContext context,
                               IRubyObject recv,
                               IRubyObject from,
                               IRubyObject to)

mtime

public static IRubyObject mtime(ThreadContext context,
                                IRubyObject recv,
                                IRubyObject filename)

rename

public static IRubyObject rename(ThreadContext context,
                                 IRubyObject recv,
                                 IRubyObject oldName,
                                 IRubyObject newName)

split

public static RubyArray split(ThreadContext context,
                              IRubyObject recv,
                              IRubyObject arg)

symlink

public static IRubyObject symlink(ThreadContext context,
                                  IRubyObject recv,
                                  IRubyObject from,
                                  IRubyObject to)

readlink

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

truncate

public static IRubyObject truncate(ThreadContext context,
                                   IRubyObject recv,
                                   IRubyObject arg1,
                                   IRubyObject arg2)

truncate19

public static IRubyObject truncate19(ThreadContext context,
                                     IRubyObject recv,
                                     IRubyObject arg1,
                                     IRubyObject arg2)

umask

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

utime

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

unlink

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

size

public IRubyObject size(ThreadContext context)

getFileEntry

public static java.util.zip.ZipEntry getFileEntry(java.util.zip.ZipFile zf,
                                                  java.lang.String path)
                                           throws java.io.IOException
Throws:
java.io.IOException

getDirOrFileEntry

public static java.util.zip.ZipEntry getDirOrFileEntry(java.util.zip.ZipFile zf,
                                                       java.lang.String path)
                                                throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2002-2009 JRuby Team. All Rights Reserved.