filesystem

package module
v0.52.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Overview

Package filesystem provides functions and types to interact with the filesystem

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(path string) bool

FileExists returns true if a file exists and is accessible, false otherwise

func GetFileModTime added in v0.52.0

func GetFileModTime(path string) (time.Time, error)

GetFileModTime gets the modification time

func GetFileSize added in v0.52.0

func GetFileSize(path string) (int64, error)

GetFileSize gets the file size

func OpenShared

func OpenShared(path string) (*os.File, error)

OpenShared reimplements the os.Open function for Windows because the default implementation opens files without the FILE_SHARE_DELETE flag. cf: https://github.com/golang/go/blob/release-branch.go1.11/src/syscall/syscall_windows.go#L271 Without FILE_SHARE_DELETE, other users cannot rename/remove the file while this handle is open. Adding this flag allows the agent to have the file open, while not preventing it from being rotated/deleted.

On non-Windows platforms, this calls through to os.Open directly.

func ReadLines

func ReadLines(filename string) ([]string, error)

ReadLines reads a file line by line

Types

type Disk

type Disk struct{}

Disk gets information about the disk

func NewDisk

func NewDisk() Disk

NewDisk creates a new instance of Disk

func (Disk) GetUsage

func (Disk) GetUsage(path string) (*DiskUsage, error)

GetUsage gets the disk usage

type DiskUsage

type DiskUsage struct {
	Total     uint64
	Available uint64
}

DiskUsage is the disk usage

type Permission

type Permission struct{}

Permission handles permissions for Unix and Windows

func NewPermission

func NewPermission() (*Permission, error)

NewPermission creates a new instance of `Permission`

func (*Permission) RemoveAccessToOtherUsers

func (p *Permission) RemoveAccessToOtherUsers(path string) error

RemoveAccessToOtherUsers on Unix this calls RestrictAccessToUser and then removes all access to the file for 'group' and 'other'

func (*Permission) RestrictAccessToUser

func (p *Permission) RestrictAccessToUser(path string) error

RestrictAccessToUser sets the file user and group to the same as 'dd-agent' user. If the function fails to lookup "dd-agent" user it return nil immediately.

Jump to

Keyboard shortcuts

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