Previous: , Up: Classes   [Index]


FileStream

FileStream Class

FileStream and its subclasses contain methods and variables that read and write to files and other I/O devices.

Instance Variables

streamMode (Class Integer)

File permissions mode.

streamDev (Class Integer)

Device ID of a file.

streamRdev (Class Integer)

Device ID if a special file.

streamSize (Class LongInteger)

File size in bytes.

streamAtime (Class LongInteger)

Time of last file access.

streamMtime (Class LongInteger)

Time of last file modification.

streamCtime (Class LongInteger)

Time of last file status change.

streamPos (Class LongInteger)

Offset of read or write operation in the file, if a regular file.

streamErrno

System error number of the last file operation, EOF at the end of the file, or 0 on success.

streamPath

A String object, containing the path name of a regular file.

Class Variables

None.

Instance Methods

= (arg)

Assign the value of the file stream in the argument to the receiver. This method does not duplicate the file handle.

closeStream (void)

Close the receiver’s input file stream. Note that closeStream does not delete the receiver object. You must call delete (Class Object) to delete the object explicitly. Deleting global and local objects is still not complete - you must check the receiver and argument stacks, and the local variables of the function or method, to make sure that the object is removed from its dictionary.

deleteFile (String file_path)

Deletes the file given as the argument. If the deletion is not successful, the method raises a SystemErrnoException which an application can check for.

exists (char *__path_name)

Return TRUE if the file exists, FALSE otherwise.

isDir (void)

Return an Integer object that evaluates to TRUE if the receiver is a directory, FALSE otherwise.

renameFile (String oldname, String newname)

Renames the file named by oldname to newname. Raises a SystemErrnoException if renaming the file causes an error.

seekTo (Integer file_pos)

Reposition the file’s reading and writing position indicator at file_pos. If the request is unsuccessful, the method raises a SystemErrnoException that a program can check for.

seekToBeginning (void)

Reposition the file’s reading and writing position indicator at the beginning of a file. If the request is unsuccessful, the method raises a SystemErrnoException that a program can check for.

seekToEnd (void)

Reposition the file’s reading and writing position indicator at the end of a file. If unsuccessful, the method raises a SystemErrnoException that programs can check for.

size (void)

Returns the size of the receiver’s file as a LongInteger.

statFile (String file_path)

A wrapper method for the C stat(2) function. This method fills in the receiver stream’s streamMode, streamDev, StreamRdev, streamSize, streamAtime, streamMtime, and streamCtime instance variables. The stream does not need to be opened on the file given by file_path.

The method returns an Integer with a value of ‘0’ on success, or if an error occurs, returns ‘-1’ and raises a SystemErrnoException.

statStream (void)

Another wrapper method for the C stat(2) function. The method fills in the streamMode, streamDev, StreamRdev, streamSize, streamAtime, streamMtime, and streamCtime instance variables of the receiver, an open file stream.

The method returns an Integer with a value of ‘0’ on success, or if an error occurs, returns ‘-1’ and raises a SystemErrnoException.

streamEof (void)

Returns a non-zero Integer object if at the end of the receiver’s file stream, a zero-value Integer otherwise.

Class Methods

None.


Previous: , Up: Classes   [Index]