disk

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// GetDiskFreeSpaceEx - https://msdn.microsoft.com/en-us/library/windows/desktop/aa364937(v=vs.85).aspx
	// Retrieves information about the amount of space that is available on a disk volume,
	// which is the total amount of space, the total amount of free space, and the total
	// amount of free space available to the user that is associated with the calling thread.
	GetDiskFreeSpaceEx = kernel32.NewProc("GetDiskFreeSpaceExW")
	// GetDiskFreeSpace - https://msdn.microsoft.com/en-us/library/windows/desktop/aa364935(v=vs.85).aspx
	// Retrieves information about the specified disk, including the amount of free space on the disk.
	GetDiskFreeSpace = kernel32.NewProc("GetDiskFreeSpaceW")
)
View Source
var (
	// GetVolumeInformation provides windows drive volume information.
	GetVolumeInformation = kernel32.NewProc("GetVolumeInformationW")
)

Functions

func DisableDirectIO

func DisableDirectIO(f *os.File) error

func IsRootDisk

func IsRootDisk(diskPath string) (bool, error)

IsRootDisk returns if diskPath belongs to root-disk, i.e the disk mounted at "/"

func OpenFileDirectIO

func OpenFileDirectIO(filePath string, flag int, perm os.FileMode) (*os.File, error)

Types

type Info

type Info struct {
	Total  uint64
	Free   uint64
	Files  uint64
	Ffree  uint64
	FSType string

	// Usage is calculated per tenant.
	Usage uint64
}

Info stat fs struct is container which holds following values Total - total size of the volume / disk Free - free size of the volume / disk Files - total inodes available Ffree - free inodes available FSType - file system type

func GetInfo

func GetInfo(path string) (info Info, err error)

GetInfo returns total and free bytes available in a directory, e.g. `C:\`. It returns free space available to the user (including quota limitations)

https://msdn.microsoft.com/en-us/library/windows/desktop/aa364937(v=vs.85).aspx

type Performance

type Performance struct {
	Path       string  `json:"path"`
	Error      string  `json:"error,omitempty"`
	WriteSpeed float64 `json:"writeSpeed"`
	ReadSpeed  float64 `json:"readSpeed"`
}

Performance holds informantion about read and write speed of a disk

func GetPerformance

func GetPerformance(path string, size int64) Performance

GetPerformance returns given disk's read and write performance

Jump to

Keyboard shortcuts

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