os

package
v0.0.0-...-ebc58a5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileModeByName = map[string]FileFlag{
	"ro":            ORo,
	"wo":            OWo,
	"rw":            ORW,
	"append":        OAppend,
	"create":        OCreate,
	"if_not_exists": OIfNotExists,
	"sync":          OSync,
	"trunc":         OTrunc,
}
View Source
var (
	Module = gad.Dict{
		"FileFlag":     TFileFlag,
		"pwd":          gad.MustNewReflectValue(os.Getwd),
		"uid":          gad.MustNewReflectValue(os.Getuid),
		"gid":          gad.MustNewReflectValue(os.Getgid),
		"homeDir":      gad.MustNewReflectValue(os.UserHomeDir),
		"user":         gad.MustNewReflectValue(user.Current),
		"getUser":      gad.MustNewReflectValue(user.Lookup),
		"getUserByID":  gad.MustNewReflectValue(user.LookupId),
		"getGroup":     gad.MustNewReflectValue(user.LookupGroup),
		"getGroupByID": gad.MustNewReflectValue(user.LookupGroupId),
		"Cmd":          gad.NewReflectType(reflect.TypeOf(cmdu.CmdBuilder{})),
		"env":          gad.MustNewReflectValue(cmdu.OsEnv),
		"mkdir":        gad.MustNewReflectValue(os.Mkdir),
		"mkdirAll":     gad.MustNewReflectValue(os.MkdirAll),
		"rm":           gad.MustNewReflectValue(os.Remove),
		"rmAll":        gad.MustNewReflectValue(os.RemoveAll),
		"stat":         gad.MustNewReflectValue(os.Stat),
		"exec": &gad.Function{
			Name:  "exec",
			Value: Exec,
		},
		"exists": &gad.Function{
			Name:  "exists",
			Value: Exists,
		},
		"createFile": &gad.Function{
			Name:  "createFile",
			Value: CreateFile,
		},
		"openFile": &gad.Function{
			Name:  "openFile",
			Value: OpenFile,
		},
		"readFile": &gad.Function{
			Name:  "readFile",
			Value: ReadFile,
		},
	}
)
View Source
var TFileFlag = &gad.Type{
	Parent:   gad.TInt,
	TypeName: "FileFlag",
	Constructor: &gad.Function{
		Value: NewFileMode,
	},
	Static: gad.Dict{
		"RO":          ORo,
		"WO":          OWo,
		"RW":          ORW,
		"Append":      OAppend,
		"Create":      OCreate,
		"IfNotExists": OIfNotExists,
		"Sync":        OSync,
		"Trunc":       OTrunc,
	},
}

Functions

func CreateFile

func CreateFile(c gad.Call) (o gad.Object, err error)

func Exec

func Exec(c gad.Call) (o gad.Object, err error)

func Exists

func Exists(c gad.Call) (o gad.Object, err error)

func NewFileMode

func NewFileMode(c gad.Call) (_ gad.Object, err error)

func OpenFile

func OpenFile(c gad.Call) (o gad.Object, err error)

func ReadFile

func ReadFile(c gad.Call) (o gad.Object, err error)

Types

type FileFlag

type FileFlag uint64
const (
	// Exactly one of ORo, OWo, or ORW must be specified.
	ORo FileFlag = syscall.O_RDONLY // open the file read-only.
	OWo FileFlag = syscall.O_WRONLY // open the file write-only.
	ORW FileFlag = syscall.O_RDWR   // open the file read-write.
	// The remaining values may be or'ed in to control behavior.
	OAppend      FileFlag = syscall.O_APPEND // append data to the file when writing.
	OCreate      FileFlag = syscall.O_CREAT  // create a new file if none exists.
	OIfNotExists FileFlag = syscall.O_EXCL   // used with OCreate, file must not exist.
	OSync        FileFlag = syscall.O_SYNC   // open for synchronous I/O.
	OTrunc       FileFlag = syscall.O_TRUNC  // truncate regular writable file when opened.
)

func (FileFlag) BinaryOp

func (f FileFlag) BinaryOp(vm *gad.VM, tok token.Token, right gad.Object) (ret gad.Object, err error)

BinaryOp implements Object interface.

func (*FileFlag) Clear

func (f *FileFlag) Clear(flag FileFlag) *FileFlag

func (FileFlag) Equal

func (f FileFlag) Equal(right gad.Object) bool

func (FileFlag) Has

func (f FileFlag) Has(flag FileFlag) bool

func (FileFlag) IsFalsy

func (f FileFlag) IsFalsy() bool

func (*FileFlag) Parse

func (f *FileFlag) Parse(str string)

func (*FileFlag) Set

func (f *FileFlag) Set(flag FileFlag) *FileFlag

func (FileFlag) String

func (f FileFlag) String() string

func (FileFlag) ToString

func (f FileFlag) ToString() string

func (*FileFlag) Toggle

func (f *FileFlag) Toggle(flag FileFlag) *FileFlag

func (FileFlag) Type

func (f FileFlag) Type() gad.ObjectType

Jump to

Keyboard shortcuts

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