ioutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

README

ioutil GoDoc

Usage

local ioutil = require("ioutil")

-- ioutil.write_file()
local err = ioutil.write_file("./test/file.data", "content of test file")
if err then error(err) end

-- ioutil.read_file()
local result, err = ioutil.read_file("./test/file.data")
if err then error(err) end
if not(result == "content of test file") then error("ioutil.read_file()") end

-- ioutil.copy()
local input_fh, err = io.open("./test/file.test", "r")
assert(not err, err)
local output_fh, err = io.open("./test/file2.data", "w")
assert(not err, err)
err = ioutil.copy(output_fh, input_fh)
assert(not err, err)
input_fh:close()
output_fh:close()

Documentation

Overview

Package ioutil implements golang package ioutil functionality for lua.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(L *lua.LState) int

func CopyN

func CopyN(L *lua.LState) int

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func Preload

func Preload(L *lua.LState)

Preload adds ioutil to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:

local ioutil = require("ioutil")

func ReadFile

func ReadFile(L *lua.LState) int

ReadFile lua ioutil.read_file(filepath) reads the file named by filename and returns the contents, returns (string,error)

func WriteFile

func WriteFile(L *lua.LState) int

WriteFile lua ioutil.write_file(filepath, data) reads the file named by filename and returns the contents, returns (string,error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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