fsutils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(path string) string

Returns the fully resolved path, even if the path does not exist.

``` fsutil.Abs("./does/not/exist") ``` If the code above was run within `/home/user`, the result would be `/home/user/does/not/exist`.

func Exists

func Exists(path string) bool

Exists is a helper method to quickly determine whether a directory or file exists.

func IsDirectory

func IsDirectory(path string) bool

IsDirectory determines whether the specified path represents a directory.

func Mkdirp

func Mkdirp(path string) string

Mkdirp is the equivalent of [mkdir -p](https://en.wikipedia.org/wiki/Mkdir) It will generate the full directory path if it does not already exist.

func ReadTextFile

func ReadTextFile(path string) (string, error)

func Touch

func Touch(path string, flags ...interface{}) string

/ Similar to the touch command on *nix, where the file or directory will be created if it does not already exist. Returns the absolute path. The optional second boolean argument will force the method to treat the path as a file instead of a directory (useful when the filename has not extension). An optional 3rd boolean argument will force the method to treat the path as a directory even if a file extension is present.

For example: `fsutil.Touch("./path/to/archive.old", false, true)`

Normally, any file path with an extension is determined to be a file. However; the second argument (`false`) instructs the command to **not** force a file. The third argument (`true`) instructs the command to **treat the path like a directory**.

func WriteTextFile

func WriteTextFile(path string, content string, args ...interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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