osfile

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package osfile is the platform layer for two things the database needs from the operating system and the standard library does not offer: an exclusive lock on a file that the OS releases when the process ends, and the free space in a folder. Like internal/hostinfo, internal/winapi and internal/winsvc it is where operating-system code lives, so nothing else has to import x/sys/windows (enforced by internal/archtest). It imports nothing else from this module.

Index

Constants

This section is empty.

Variables

View Source
var ErrLocked = errors.New("the file is locked by another process")

ErrLocked is returned by TryLock when another open of the file (in any process) holds the lock.

View Source
var ErrUnsupported = errors.New("not supported on this operating system")

ErrUnsupported is returned where an operation does not exist on this operating system.

Functions

func FreeBytes

func FreeBytes(dir string) (uint64, error)

FreeBytes is how much space an unprivileged process may still write in dir.

func TryLock

func TryLock(f *os.File) error

TryLock takes an exclusive flock on f without waiting. flock belongs to the open file, so a second open of the same file, in this process or another, is refused too.

func Unlock

func Unlock(f *os.File) error

Unlock gives the lock back (closing f does too).

Types

This section is empty.

Jump to

Keyboard shortcuts

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