stat

package
Version: v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: BSD-2-Clause Imports: 10 Imported by: 3

Documentation

Overview

Package stat provides functionality to handle 9p stat values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OsMode

func OsMode(mode Mode) os.FileMode

OsMode translates Mode to os.FileMode.

Types

type Mode

type Mode uint32

Mode represents modes of a directory entry.

const (
	// SetGid is setgid (Unix, 9P2000.u)
	SetGid Mode = 0x00040000

	// SetUid is setuid (Unix, 9P2000.u)
	SetUid Mode = 0x00080000

	// Socket is a socket (Unix, 9P2000.u)
	Socket Mode = 0x00100000

	// NamedPipe is a named pipe (Unix, 9P2000.u)
	NamedPipe Mode = 0x00200000

	// Device is a device file (Unix, 9P2000.u)
	Device Mode = 0x00800000

	// Symlink is a symbolic link (Unix, 9P2000.u)
	Symlink Mode = 0x02000000

	// Tmp is a non-backed-up file
	Tmp Mode = 0x04000000

	// Auth is a authentication file
	Auth Mode = 0x08000000

	// Mount is a mounted channel
	Mount Mode = 0x10000000

	// Excl is a exclusive use file
	Excl Mode = 0x20000000

	// Append is a append only file
	Append Mode = 0x40000000

	// Dir is a directory
	Dir Mode = 0x80000000
)

func NeinMode

func NeinMode(osmode os.FileMode) Mode

NeinMode converts os.FileMode to Mode.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader is a reader for multiple Stats, aka directories.

func NewReader

func NewReader(stats ...Stat) *Reader

NewReader returns a new Reader initialized with stats and ready for reading.

func (*Reader) Read

func (s *Reader) Read(p []byte) (int, error)

func (*Reader) Seek

func (s *Reader) Seek(offset int64, whence int) (int64, error)

Seek interface implementation.

type Stat

type Stat struct {
	//	Size   uint16
	Typ    uint16
	Dev    uint32
	Qid    qid.Qid
	Mode   Mode
	Atime  time.Time
	Mtime  time.Time
	Length uint64
	Name   string
	Uid    string
	Gid    string
	Muid   string
}

Stat contains file attributes.

Typ and Dev are usually unused. Qid contains the Qid of this file. Mode is a combination of UNIX-permission bits for owner, group and others. Atime contains the time of last access, Mtime the time of last modification. Length is the file length in bytes, directories have a conventional length of 0. Name is the file name and must be "/" if the file is the root directory of the server. Uid is the owners name (not UNIX uid), group is the groups name. Muid is the name of the last user who modified the file.

http://man.cat-v.org/inferno/5/stat

func FileInfo

func FileInfo(fi os.FileInfo) Stat

FileInfo creates Stat using os.FileInfo.Sys(). If using the information returned by Sys() fails, it returns a stat like returned by GenericStat.

func Generic

func Generic(fi os.FileInfo) Stat

Generic creates a neinp.Stat not using FileInfo.Sys().

func (*Stat) Decode

func (s *Stat) Decode(r io.Reader) (int64, error)

func (*Stat) Encode

func (s *Stat) Encode(w io.Writer) (int64, error)

func (*Stat) IsAppend

func (s *Stat) IsAppend() bool

IsAppend returns true if Append is set.

func (*Stat) IsAuth

func (s *Stat) IsAuth() bool

IsAuth returns true if Auth is set.

func (*Stat) IsDevice

func (s *Stat) IsDevice() bool

IsDevice returns true if Device is set.

func (*Stat) IsDir

func (s *Stat) IsDir() bool

IsDir returns true if Dir is set.

func (*Stat) IsExcl

func (s *Stat) IsExcl() bool

IsExcl returns true if Excl is set.

func (*Stat) IsMount

func (s *Stat) IsMount() bool

IsMount returns true if Mount is set.

func (*Stat) IsNamedPipe

func (s *Stat) IsNamedPipe() bool

IsNamedPipe returns true if NamedPipe is set.

func (*Stat) IsSetGid

func (s *Stat) IsSetGid() bool

IsSetGid returns true if SetGid is set

func (*Stat) IsSetUid

func (s *Stat) IsSetUid() bool

IsSetUid returns true if SetUid is set.

func (*Stat) IsSocket

func (s *Stat) IsSocket() bool

IsSocket returns true if Socket is set.

func (s *Stat) IsSymlink() bool

IsSymlink returns true if Symlink is set.

func (*Stat) IsTmp

func (s *Stat) IsTmp() bool

IsTmp returns true if Tmp is set.

Jump to

Keyboard shortcuts

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