fileapi

package
v0.0.0-...-3547e8a Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 8 Imported by: 2

Documentation

Overview

Package fileapi provides access to advanced functions in the Windows file system API.

Index

Constants

View Source
const (
	FileBasicInfo = iota
	FileStandardInfo
	FileNameInfo
	FileRenameInfo
	FileDispositionInfo
	FileAllocationInfo
	FileEndOfFileInfo
	FileStreamInfo
	FileCompressionInfo
	FileAttributeTagInfo
	FileIDBothDirectoryInfo
	FileIDBothDirectoryRestartInfo
	FileIoPriorityHintInfo
	FileRemoteProtocolInfo
	FileFullDirectoryInfo
	FileFullDirectoryRestartInfo
	FileStorageInfo
	FileAlignmentInfo
	FileIDInfo
	FileIDExtdDirectoryInfo
	FileIDExtdDirectoryRestartInfo
	FileDispositionInfoEx
	FileRenameInfoEx
	FileCaseSensitiveInfo
	FileNormalizedNameInfo
)

File information classes.

Variables

View Source
var (
	// ErrEmptyBuffer is returned when a nil or zero-sized buffer is provided
	// to a system call.
	ErrEmptyBuffer = errors.New("nil or empty buffer provided")
)

Functions

func GetFileInformationByHandle

func GetFileInformationByHandle(handle syscall.Handle) (info syscall.ByHandleFileInformation, err error)

GetFileInformationByHandle retrieves standard information about the file represented by the given system handle.

func GetFileInformationByHandleEx

func GetFileInformationByHandleEx(handle syscall.Handle, info FileInfoUnmarshaler) (err error)

GetFileInformationByHandleEx retrieves information about the file represented by the given system handle. The type of information returned is determined by class.

func OpenFileByID

func OpenFileByID(peer syscall.Handle, id fileref.ID, access, shareMode, flags uint32) (handle syscall.Handle, err error)

OpenFileByID opens a file by its file ID. The file will be opened with the given access, share mode and flags.

The handle provided can be to any file or on the volume, or to the volume itself.

func ReOpenFile

func ReOpenFile(original syscall.Handle, access, shareMode, flags uint32) (handle syscall.Handle, err error)

ReOpenFile opens a file by its file ID. The file will be opened with the given access, share mode and flags.

The handle provided can be to any file or on the volume, or to the volume itself.

func SetFileInformationByHandle

func SetFileInformationByHandle(handle syscall.Handle, info FileInfoMarshaler) (err error)

SetFileInformationByHandle updates the file identified by the given system handle. The type of information file information set is determined by class.

Types

type BasicInfo

type BasicInfo struct {
	CreationTime   time.Time
	LastAccessTime time.Time
	LastWriteTime  time.Time
	ChangeTime     time.Time
	FileAttributes fileattr.Value
}

BasicInfo stores basic information about a file. It can be marsheled into the FILE_BASIC_INFO windows API structure.

func (BasicInfo) Bytes

func (info BasicInfo) Bytes() (data []byte)

Bytes marshals info as binary data suitable for use with API calls.

func (BasicInfo) Class

func (info BasicInfo) Class() FileInfoClass

Class returns the file information class.

func (BasicInfo) MarshalBinary

func (info BasicInfo) MarshalBinary() (data []byte, err error)

MarshalBinary marshals info as binary data suitable for use with API calls.

func (*BasicInfo) Size

func (info *BasicInfo) Size() int

Size returns the the number of bytes required to store BasicInfo in its marshaled form.

func (*BasicInfo) UnmarshalBinary

func (info *BasicInfo) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the given data into info.

type FileInfo

type FileInfo interface {
	Class() FileInfoClass
}

FileInfo is a type that holds file information data.

type FileInfoClass

type FileInfoClass int

FileInfoClass identifies the class of file information being accessed in file system API calls.

type FileInfoForHandle

type FileInfoForHandle struct {
	FileName string
	syscall.ByHandleFileInformation
}

FileInfoForHandle implements the fs.FileInfo interface. It stores data in a form that is convenient when accessing files by their handle or file reference number.

func (FileInfoForHandle) IsDir

func (fi FileInfoForHandle) IsDir() bool

IsDir returns true if the file is a directory.

func (FileInfoForHandle) ModTime

func (fi FileInfoForHandle) ModTime() time.Time

ModTime returns the last modification time of the file.

func (FileInfoForHandle) Mode

func (fi FileInfoForHandle) Mode() (m os.FileMode)

Mode returns the mode of the file.

FIXME: This does not properly indicate whether a file is a symlink.

func (FileInfoForHandle) Name

func (fi FileInfoForHandle) Name() string

Name returns the name of the file.

func (FileInfoForHandle) Size

func (fi FileInfoForHandle) Size() int64

Size returns the size of the file in bytes.

func (FileInfoForHandle) Sys

func (fi FileInfoForHandle) Sys() any

Sys returns implementation-specific details. It returns nil.

type FileInfoMarshaler

type FileInfoMarshaler interface {
	FileInfo
	MarshalBinary() (data []byte, err error)
}

FileInfoMarshaler is a file information data type that can be marshaled into a form acceptable to the file system APIs.

type FileInfoUnmarshaler

type FileInfoUnmarshaler interface {
	FileInfo
	Size() int
	UnmarshalBinary(data []byte) error
}

FileInfoMarshaler is a file information data type that can be unmarshaled from file system APIs.

type RenameInfo

type RenameInfo struct {
	ReplaceIfExists bool
	FileName        string
}

RenameInfo stores basic information about a file. It can be marsheled into the FILE_RENAME_INFO windows API structure.

func (RenameInfo) Class

func (info RenameInfo) Class() FileInfoClass

Class returns the file information class.

func (RenameInfo) MarshalBinary

func (info RenameInfo) MarshalBinary() (data []byte, err error)

MarshalBinary marshals info as binary data suitable for use with API calls.

Jump to

Keyboard shortcuts

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