file

package
v0.0.0-...-cfb4354 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2020 License: Zlib Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileTag tagFile

FileTag is the Tag for File objects. Activate returns self. CloneValue returns a new, unopened file with an empty path and mode set to "update".

Functions

func New

func New(vm *iolang.VM, file *os.File, mode string) *iolang.Object

New creates a File object with the given file. The mode string should be one of "read", "update", or "append", depending on the flags used when opening the file.

func NewAt

func NewAt(vm *iolang.VM, path string) *iolang.Object

NewAt creates a File object unopened at the given path. The mode will be set to "read". The path should use the OS's separator convention.

Types

type File

type File struct {
	File *os.File
	// Path is in the OS's convention internally, but Io-facing methods convert
	// it to slash-separated.
	Path string
	Mode string
	EOF  bool // no equivalent to feof() in Go
}

A File is an object allowing interfacing with the operating system's files.

func (File) ReadLine

func (f File) ReadLine() (line []byte, eof bool, err error)

ReadLine reads one line from the file such that the file cursor will be positioned after the first encountered newline. The line without the newline is returned, along with any error, which may include io.EOF. If the file reaches EOF while reading, then the returned eof value will be true.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL