osutil

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT-0 Imports: 10 Imported by: 0

Documentation

Overview

Package osutil provides additional platform-independent access to operating system functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupArgs

func CleanupArgs()

CleanupArgs cleans up os.Args. On macOS, it removes the Process Serial Number arg.

func Copy

func Copy(src, dst string) (err error)

Copy copies src to dst.

func CreateConsole

func CreateConsole() error

CreateConsole ensures a Windows process has an attached console. If needed, it creates an hidden console and attaches to it.

func GetANSIPath

func GetANSIPath(path string) (string, error)

GetANSIPath converts path so that it is valid for use with Windows ANSI APIs. Outside of Windows, path is returned unchanged.

On Windows, if path length exceeds MAX_PATH, or if it contains characters that cannot be represented in the system's ANSI code page, GetShortPathName is used to try to construct an equivalent, valid path.

Note: path is assumed to be UTF-8 encoded, and is returned UTF-8 encoded. GetANSIPath can be used to obtain an equivalent path that you can offer as a command line argument to an external program that uses ANSI APIs, not to encode path so that you can access ANSI APIs directly.

func HiddenFile

func HiddenFile(de os.DirEntry) bool

HiddenFile reports whether de is hidden. Files starting with a period are reported as hidden on all systems, even Windows. Other than that, plaform rules apply.

func Lnky

func Lnky(src, dst string) error

Lnky copies src to dst. Tries os.Link to create a hardlink. Failing that, does a Copy.

func Move

func Move(src, dst string) error

Move moves src to dst. Tries os.Rename. Failing that, does a Copy followed by a os.Remove.

func NewFile

func NewFile(name string) (*os.File, error)

NewFile creates a new named file. If the file already exists, a numeric suffix is appended or incremented.

func SetPriority added in v0.10.0

func SetPriority(proc os.Process, prio PriorityClass) error

SetPriority sets the scheduling priority of proc.

func ShellOpen

func ShellOpen(file string) error

ShellOpen opens a file (or a directory, or URL), just as if you had double-clicked the file's icon.

Types

type PriorityClass added in v0.10.0

type PriorityClass int
const (
	Realtime    PriorityClass = -20
	High        PriorityClass = -16
	AboveNormal PriorityClass = -8
	Normal      PriorityClass = 0
	BelowNormal PriorityClass = 8
	Idle        PriorityClass = 16
)

Jump to

Keyboard shortcuts

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