All Implemented Interfaces:
Closeable, AutoCloseable

public class OpenRestrictedFile extends OpenFile
A File where no FileChannel to the data is opened. Should be useed, if the file is e.g. invalid but should be deleteable.
  • Constructor Details

    • OpenRestrictedFile

      public OpenRestrictedFile(Path path)
  • Method Details

    • read

      public int read(com.sun.jna.Pointer buf, int num, long offset) throws IOException
      Description copied from class: OpenFile
      Reads up to num bytes beginning at offset into buf
      Overrides:
      read in class OpenFile
      Parameters:
      buf - Buffer
      num - Number of bytes to read
      offset - Position of first byte to read
      Returns:
      Actual number of bytes read (can be less than num if reached EOF).
      Throws:
      IOException - If an exception occurs during read.
    • write

      public int write(com.sun.jna.Pointer buf, int num, long offset) throws IOException
      Description copied from class: OpenFile
      Writes up to num bytes from buf into the current file beginning at offset
      Overrides:
      write in class OpenFile
      Parameters:
      buf - Buffer
      num - Number of bytes to write
      offset - Position of first byte to write at
      Returns:
      Actual number of bytes written TODO: only the bytes which contains information or also some filling zeros?
      Throws:
      IOException - If an exception occurs during write.
    • flush

      public void flush() throws IOException
      Overrides:
      flush in class OpenFile
      Throws:
      IOException
    • truncate

      public void truncate(long size) throws IOException
      Overrides:
      truncate in class OpenFile
      Throws:
      IOException
    • canBeDeleted

      public boolean canBeDeleted()
      Description copied from class: OpenFile
      Test if we can delete this file.
      Overrides:
      canBeDeleted in class OpenFile
      Returns:
      true if no concurrent routine holds a lock on this file or the file is opened as read-only
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OpenFile
      Throws:
      IOException
    • open

      public static OpenRestrictedFile open(Path path)