fs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: PostgreSQL Imports: 3 Imported by: 0

Documentation

Overview

Package fs is a general library of filesystem things.

Index

Constants

View Source
const (
	OS_READ        = 04
	OS_WRITE       = 02
	OS_EX          = 01
	OS_USER_SHIFT  = 6
	OS_GROUP_SHIFT = 3
	OS_OTH_SHIFT   = 0

	OS_USER_R   = OS_READ << OS_USER_SHIFT
	OS_USER_W   = OS_WRITE << OS_USER_SHIFT
	OS_USER_X   = OS_EX << OS_USER_SHIFT
	OS_USER_RW  = OS_USER_R | OS_USER_W
	OS_USER_RWX = OS_USER_RW | OS_USER_X

	OS_GROUP_R   = OS_READ << OS_GROUP_SHIFT
	OS_GROUP_W   = OS_WRITE << OS_GROUP_SHIFT
	OS_GROUP_X   = OS_EX << OS_GROUP_SHIFT
	OS_GROUP_RW  = OS_GROUP_R | OS_GROUP_W
	OS_GROUP_RWX = OS_GROUP_RW | OS_GROUP_X

	OS_OTH_R   = OS_READ << OS_OTH_SHIFT
	OS_OTH_W   = OS_WRITE << OS_OTH_SHIFT
	OS_OTH_X   = OS_EX << OS_OTH_SHIFT
	OS_OTH_RW  = OS_OTH_R | OS_OTH_W
	OS_OTH_RWX = OS_OTH_RW | OS_OTH_X

	OS_ALL_R   = OS_USER_R | OS_GROUP_R | OS_OTH_R
	OS_ALL_W   = OS_USER_W | OS_GROUP_W | OS_OTH_W
	OS_ALL_X   = OS_USER_X | OS_GROUP_X | OS_OTH_X
	OS_ALL_RW  = OS_ALL_R | OS_ALL_W
	OS_ALL_RWX = OS_ALL_RW | OS_GROUP_X
)

Unix file modes https://stackoverflow.com/a/42718395 Note: Creating files/directories on Unix will conform to the umask settings and may not use the mode specified. A workaround is to change the mode after the file/directory is created since umask affects the mode during creation, not afterwards.

Variables

This section is empty.

Functions

func Exists

func Exists(path string) bool

Exists returns true if the path exists (file or directory) https://stackoverflow.com/a/12527546 https://stefanxo.com/go-anti-patterns-os-isexisterr-os-isnotexisterr/

func GetContents

func GetContents(path *string) (contents []byte, err error)

GetContents will get the contents of a file.

func IsDir

func IsDir(path string) bool

IsDir returns true if path is a directory.

func IsFile

func IsFile(path string) bool

IsFile returns true if path is a file.

func SetExecute

func SetExecute(path string) (err error)

SetExecute will set the execution bit for all on Unix without changing the other bits.

Types

This section is empty.

Jump to

Keyboard shortcuts

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