Class WasiFileStub

    • Constructor Detail

      • WasiFileStub

        public WasiFileStub()
    • Method Detail

      • read

        public int read​(byte[] buffer,
                        int offset,
                        int length)
                 throws IOException
        Description copied from interface: ReadableIO
        Reads length bytes of data from this WasiIO into an array of bytes.
        Specified by:
        read in interface ReadableIO
        Parameters:
        buffer - the buffer into which the data is read.
        offset - the start offset in array b at which the data is written.
        length - the maximum number of bytes to read.
        Returns:
        the total number of bytes read into the buffer or -1 if there is no more data.
        Throws:
        IOException - if an I/O error occurs.
      • available

        public int available()
                      throws IOException
        Description copied from interface: ReadableIO
        Returns an estimate of the number of bytes that can be read from this input stream without blocking by the next read method invocation.
        Specified by:
        available in interface ReadableIO
        Returns:
        an estimate of the number of bytes that can be read from this input stream without blocking or 0 when it reaches the end of this WasiIO.
        Throws:
        IOException - if an I/O error occurs.
      • setNonBlocking

        public void setNonBlocking​(boolean on)
                            throws IOException
        Description copied from interface: ReadableIO
        Sets this WasiIO in non blocking state.
        Specified by:
        setNonBlocking in interface ReadableIO
        Parameters:
        on - whether to enable or disable the non blocking option.
        Throws:
        IOException - if an I/O error occurs.
      • getType

        public FileType getType()
        Description copied from interface: WasiIO
        Gets the WasiIO file descriptor type.
        Specified by:
        getType in interface WasiIO
        Returns:
        the WasiIO file descriptor type.
      • close

        public void close()
                   throws IOException
        Description copied from interface: Closeable
        Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        IOException - if an I/O error occurs
      • write

        public void write​(byte[] buffer,
                          int offset,
                          int length)
                   throws IOException
        Description copied from interface: WritableIO
        Writes length bytes from t he specified byte array starting at offset offset to this WasiIO.
        Specified by:
        write in interface WritableIO
        Parameters:
        buffer - the data to write.
        offset - the starting offset.
        length - the number of bytes to write.
        Throws:
        IOException - if an I/O error occurs.
      • wasiSetLength

        public void wasiSetLength​(long length)
                           throws IOException
        Description copied from interface: WasiFile
        Sets the length of a file. If file is shortened, the data is lost, if file is grown, the new data is filled with zeros.
        Specified by:
        wasiSetLength in interface WasiFile
        Parameters:
        length - The new length to set for the file.
        Throws:
        IOException - If an io error occurs
      • length

        public long length()
        Specified by:
        length in interface WasiFile