fs

package module
v0.0.0-...-ad47e6d Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFileFromParent

func GetFileFromParent(root string, start string, search string) (string, bool)

GetFileFromParent checks if the parent (or sub parent) directory of a file contains a specific file or folder

@root is the highest grandparent to check before quitting

@start is the lowest level to start searching from (if a directory is passed, it will not be included in your search)

@search is what file you want to search from

func JoinPath

func JoinPath(path ...string) (string, error)

JoinPath joins multiple file types with safety from backtracking

Types

type FileWatcher

type FileWatcher struct {

	// when a file changes
	//
	// @path: the file path the change happened to
	//
	// @op: the change operation
	OnFileChange func(path string, op string)

	// when a directory is added
	//
	// @path: the file path the change happened to
	//
	// @op: the change operation
	//
	// return false to prevent that directory from being watched
	OnDirAdd func(path string, op string) (addWatcher bool)

	// when a file or directory is removed
	//
	// @path: the file path the change happened to
	//
	// @op: the change operation
	//
	// return false to prevent that directory from no longer being watched
	OnRemove func(path string, op string) (removeWatcher bool)

	// every time something happenes
	//
	// @path: the file path the change happened to
	//
	// @op: the change operation
	OnAny func(path string, op string)
	// contains filtered or unexported fields
}

A watcher instance for the `FS.FileWatcher` method

func Watcher

func Watcher() *FileWatcher

func (*FileWatcher) CloseWatcher

func (fw *FileWatcher) CloseWatcher(root string) error

CloseWatcher will close the watcher by the root name you used

@root pass a file path for a specific watcher or "*" for all watchers that exist

func (*FileWatcher) Wait

func (fw *FileWatcher) Wait()

Wait for all Watchers to close

func (*FileWatcher) WatchDir

func (fw *FileWatcher) WatchDir(root string) error

WatchDir watches the files in a directory and its subdirectories for changes

type LinuxPKG

type LinuxPKG struct {
	// contains filtered or unexported fields
}

linux package installer

func (*LinuxPKG) GetLinuxInstaller

func (linuxPKG *LinuxPKG) GetLinuxInstaller(man []string) string

GetLinuxInstaller attempt to find out what package manager a linux distro is using or has available

func (*LinuxPKG) HasLinuxPkg

func (linuxPKG *LinuxPKG) HasLinuxPkg(pkg []string) bool

HasLinuxPkg attempt to check if a linux package is installed

func (*LinuxPKG) InstallLinuxPkg

func (linuxPKG *LinuxPKG) InstallLinuxPkg(pkg []string, man ...string)

InstallLinuxPkg attempts to install a linux package

this method will also resolve the sudo command and ask for a user password if needed

this method will not attempt to run an install, if it finds the package is already installed

Jump to

Keyboard shortcuts

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