Interface FileResource

All Known Implementing Classes:
URLResource

public interface FileResource
This is a shared interface for files loaded as File and ZipEntry.
  • Method Details

    • wrap

      static FileResource wrap(jnr.posix.POSIX posix, JRubyFile file)
    • absolutePath

      String absolutePath()
    • canonicalPath

      String canonicalPath()
    • path

      String path()
    • exists

      boolean exists()
    • isDirectory

      boolean isDirectory()
    • isFile

      boolean isFile()
    • canExecute

      boolean canExecute()
    • errno

      int errno()
    • lastModified

      long lastModified()
    • length

      long length()
    • canRead

      boolean canRead()
    • canWrite

      boolean canWrite()
    • isNull

      default boolean isNull()
      Returns:
      is this a NUL device?
    • list

      String[] list()
      See Also:
    • isSymLink

      boolean isSymLink()
    • stat

      jnr.posix.FileStat stat()
    • lstat

      jnr.posix.FileStat lstat()
    • unwrap

      <T> T unwrap(Class<T> type) throws UnsupportedOperationException
      Unwrap the resource backend (replacement for hackyGetJRubyFile()).
      Type Parameters:
      T -
      Parameters:
      type -
      Returns:
      backend if supported
      Throws:
      UnsupportedOperationException
    • hackyGetJRubyFile

      @Deprecated default JRubyFile hackyGetJRubyFile()
      Deprecated.
    • inputStream

      @Deprecated(since="9.4-") default InputStream inputStream() throws ResourceException
      Deprecated.
      Opens 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.
      Returns:
      just opened InputStream
      Throws:
      ResourceException - is the file does not exists or if the resource is a directory
    • openInputStream

      InputStream openInputStream() throws IOException
      Opens 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.
      Returns:
      InputStream
      Throws:
      IOException
    • openChannel

      @Deprecated(since="9.4-") default Channel openChannel(ModeFlags flags, int perm) throws ResourceException
      Deprecated.
      Parameters:
      flags -
      perm -
      Returns:
      channel
      Throws:
      ResourceException
    • openChannel

      Channel openChannel(int flags, int perm) throws IOException
      Throws:
      IOException