Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
BEGIN LICENSE BLOCK ***** Version: EPL 1.0/GPL 2.0/LGPL 2.1 The contents of this file are subject to the Eclipse Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.eclipse.org/legal/epl-v10.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyright (C) 2008-2009 The JRuby Community <www.jruby.org> Alternatively, the contents of this file may be used under the terms of either of the GNU General Public License Version 2 or later (the "GPL"), or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which case the provisions of the GPL or the LGPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of either the GPL or the LGPL, and not to allow others to use your version of this file under the terms of the EPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL or the LGPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the EPL, the GPL or the LGPL. END LICENSE BLOCK ***
 
 package org.jruby.util.io;
 
 import org.jruby.Ruby;

 
 public interface Stream {
     static final int SEEK_SET = 0;
     static final int SEEK_CUR = 1;
     static final int SEEK_END = 2;
 
     // We use a highly uncommon string to represent the paragraph delimiter (100% soln not worth it)
     static final ByteList PARAGRAPH_DELIMETER = ByteList.create("PARAGRPH_DELIM_MRK_ER");
 
     static final ByteList PARAGRAPH_SEPARATOR = ByteList.create("\n\n");
 
 
     void clearerr();
 
     ModeFlags getModes();
     
     void setModes(ModeFlags modeFlags);
 
     boolean isSync();
 
     void setSync(boolean sync);
 
     ByteList fgets(ByteList separatorStringthrows IOExceptionBadDescriptorExceptionEOFException;
Read all bytes up to and including a terminator byte.

If the terminator byte is found, it will be the last byte in the output buffer.

Parameters:
dst The output buffer.
terminator The byte to terminate reading.
Returns:
The number of bytes read, or -1 if EOF is reached.
Throws:
java.io.IOException
BadDescriptorException
 
     int getline(ByteList dstbyte terminatorthrows IOExceptionBadDescriptorException;

    
Reads all bytes up to and including a terminator byte or until limit is reached.

If the terminator byte is found, it will be the last byte in the output buffer.

Parameters:
dst The output buffer.
terminator The byte to terminate reading.
limit the number of bytes to read unless EOF or terminator is found
Returns:
The number of bytes read, or -1 if EOF is reached.
Throws:
java.io.IOException
BadDescriptorException
 
     int getline(ByteList dstbyte terminatorlong limitthrows IOExceptionBadDescriptorException;
 
     // TODO: We overflow on large files...We could increase to long to limit
     // this, but then the impl gets more involved since java io APIs based on
     // int (means we have to chunk up a long into a series of int ops).
 
     ByteList fread(int numberthrows IOExceptionBadDescriptorExceptionEOFException;
    int fwrite(ByteList stringthrows IOExceptionBadDescriptorException;
    int ungetc(int c);
    void fputc(int cthrows IOExceptionBadDescriptorException;
    ByteList read(int numberthrows IOExceptionBadDescriptorExceptionEOFException;
    void fclose() throws IOExceptionBadDescriptorException;
    int fflush() throws IOExceptionBadDescriptorException;

    

Flush and sync all writes to the filesystem.

Throws:
java.io.IOException if the sync does not work
    void sync() throws IOExceptionBadDescriptorException;

    

Return true when at end of file (EOF).

Returns:
true if at EOF; false otherwise
Throws:
java.io.IOException
BadDescriptorException
    boolean feof() throws IOExceptionBadDescriptorException;

    

Get the current position within the file associated with this handler.

Returns:
the current position in the file.
Throws:
java.io.IOException
PipeException ESPIPE (illegal seek) when not a file

Perform a seek based on pos().

    void lseek(long offsetint typethrows IOExceptionInvalidValueExceptionPipeExceptionBadDescriptorException;
    void ftruncate(long newLengththrows IOExceptionPipeException,
            InvalidValueExceptionBadDescriptorException;

    
Implement IO#ready? as per io/wait in MRI. returns non-nil if input available without blocking, or nil.
    int ready() throws IOException;

    
Implement IO#wait as per io/wait in MRI. waits until input available or timed out and returns self, or nil when EOF reached. The default implementation loops while ready returns 0.
    boolean readDataBuffered();
    boolean writeDataBuffered();
    boolean isBlocking();
    void setBlocking(boolean blockingthrows IOException;
    void setBinmode();
    boolean isBinmode();
    boolean isAutoclose();
    void setAutoclose(boolean autoclose);
New to GrepCode? Check out our FAQ X