sys::Obj sys::File
public final class File
File is used to manage I/O to a "file". A Sedona VM may support multiple file backing storage devices via FileStore subclasses.
public Obj fp
public inline InStream in
public Str name
public inline OutStream out
public FileStore store
public void File()
File constructor.
public bool close()
Close this file. Return true on success or false on failure.
public bool exists()
Return if the file identified by name exists on the file system. This method may used without opening the file.
public bool open(Str mode)
Open the file using the configured name field. Mode is a string how IO will be performed:
- "r": open for reading - "w": open for writing (truncate existing) - "m": open for modification and read/writing (don't truncate)
Return true on success or false on error.
Note although the mode strings are passed as simply "r", "w", or "m", it is expected that files are always opened for binary IO - for example "w" maps to the C fopen mode of "wb".
public bool seek(int pos)
Seek to a specific byte offset position in the file. Return true on success or false on failure. A failure typically indicates a seek past the file limit of the device's "file system". Use tell to read the current position.
public int size()
Return the size in bytes of the file, or -1 if the file does not exist or cannot currently be accessed (e.g. if open for writing). This method may used without opening the file.
public int tell()
Return the current byte offset position of the file. Use seek to change the current position. Returns -1 on an error.