FileStream
Object Hierarchy:
Description:
[ Compact ]
[ CCode ( cname = "FILE" , free_function = "fclose" ) ]
public class FileStream
Used to control a I/O stream
Example: Read chars from a stream:
public static int main (string[] args) {
// Opens "foo.txt" for reading ("r")
FileStream stream = FileStream.open ("filestream.vala", "r");
assert (stream != null);
// buffered:
char buf[100];
while (stream.gets (buf) != null) {
print ((string) buf);
}
return 0;
}
valac --pkg glib-2.0 GLib.FileStream.gets.vala
Content:
Constants:
Static methods:
Methods:
- public void clearerr ()
- public bool eof ()
Checks if the end of the given file stream has been reached.
- public int error ()
Checks the given stream for errors.
- public int fileno ()
Returns the file descriptor for a open file.
- public int flush ()
Causes the output file stream to be synchronized with the actual
contents of the file.
- public int getc ()
Reads the next character from the given input stream.
- public unowned string? gets (char[] s)
Reads at most s.length - 1
characters from the given file
stream and stores them in s
.
- public void printf (string format, ...)
Writes the results to a file stream stream.
- public int putc (char c)
Writes a character c
to the given output stream stream.
- public int puts (string s)
Writes string s
to the given output stream
- public size_t read (uint8[] buf, size_t size = 1)
Reads specified number of objects in the array buffer from the given
input stream stream.
- public string? read_line ()
Reads a line, including the terminating character(s), from a IOChannel
into a newly-allocated string.
- public void rewind ()
Moves the file position indicator to the beginning of the given file
stream.
- public int scanf (string format, ...)
Reads the data from stream.
- public int seek (long offset, FileSeek whence)
Sets the file position indicator for the file stream stream to the
value pointed to by offset.
- public long tell ()
Returns the file position indicator for the file stream stream.
- public int ungetc (int c)
Puts the character ch back to the given file stream.
- public void vprintf (string format, va_list args)
Loads the data from the locations, defined by vlist, converts them to
character string equivalents and writes the results to a variety of sinks.
- public size_t write (uint8[] buf, size_t size = 1)
Writes count of objects in the given array buffer to the output stream
stream.