Package org.jruby.util
Class RegularFileResource
java.lang.Object
org.jruby.util.RegularFileResource
- All Implemented Interfaces:
FileResource
Represents a "regular" file, backed by regular file system.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final JRubyFileprivate BasicFileAttributesprivate final Stringprivate final jnr.posix.POSIX -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRegularFileResource(jnr.posix.POSIX posix, String filename) (package private)RegularFileResource(jnr.posix.POSIX posix, JRubyFile file, String filePath) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleancanRead()booleancanWrite()private ChannelcreateChannel(ModeFlags flags) interrno()booleanexists()booleanbooleanisFile()booleanlonglonglength()String[]list()jnr.posix.FileStatlstat()(package private) static IOExceptionopenChannel(int flags, int perm) Opens a new input stream to read the contents of a resource and returns it.path()private BasicFileAttributesjnr.posix.FileStatstat()private voidthrowFromErrno(int err) toString()<T> TUnwrap the resource backend (replacement forFileResource.hackyGetJRubyFile()).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jruby.util.FileResource
hackyGetJRubyFile, inputStream, isNull, openChannel
-
Field Details
-
file
-
filePath
-
posix
private final jnr.posix.POSIX posix -
fileAttributes
-
-
Constructor Details
-
RegularFileResource
-
RegularFileResource
-
-
Method Details
-
absolutePath
- Specified by:
absolutePathin interfaceFileResource
-
canonicalPath
- Specified by:
canonicalPathin interfaceFileResource
-
path
- Specified by:
pathin interfaceFileResource
-
length
public long length()- Specified by:
lengthin interfaceFileResource
-
lastModified
public long lastModified()- Specified by:
lastModifiedin interfaceFileResource
-
lastModifiedTime
- Throws:
IOException
-
lastAccessTime
- Throws:
IOException
-
creationTime
- Throws:
IOException
-
readAttributes
- Throws:
IOException
-
exists
public boolean exists()- Specified by:
existsin interfaceFileResource
-
canExecute
public boolean canExecute()- Specified by:
canExecutein interfaceFileResource
-
errno
public int errno()- Specified by:
errnoin interfaceFileResource
-
isFile
public boolean isFile()- Specified by:
isFilein interfaceFileResource
-
isDirectory
public boolean isDirectory()- Specified by:
isDirectoryin interfaceFileResource
-
isSymLink
public boolean isSymLink()- Specified by:
isSymLinkin interfaceFileResource
-
canRead
public boolean canRead()- Specified by:
canReadin interfaceFileResource
-
canWrite
public boolean canWrite()- Specified by:
canWritein interfaceFileResource
-
list
- Specified by:
listin interfaceFileResource- See Also:
-
stat
public jnr.posix.FileStat stat()- Specified by:
statin interfaceFileResource
-
lstat
public jnr.posix.FileStat lstat()- Specified by:
lstatin interfaceFileResource
-
toString
-
openInputStream
Description copied from interface:FileResourceOpens a new input stream to read the contents of a resource and returns it. Note that implementations may be allocating native memory for the stream, so callers need to close this when they are done with it. users of this method should follow the pattern: close the stream where you open it.- Specified by:
openInputStreamin interfaceFileResource- Returns:
- InputStream
- Throws:
IOException
-
openChannel
- Specified by:
openChannelin interfaceFileResource- Throws:
IOException
-
createChannel
- Throws:
IOException
-
unwrap
Description copied from interface:FileResourceUnwrap the resource backend (replacement forFileResource.hackyGetJRubyFile()).- Specified by:
unwrapin interfaceFileResource- Returns:
- backend if supported
-
mapFileNotFoundOnGetChannel
-
throwFromErrno
- Throws:
IOException
-