fs

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FileBackupSuffix = ".bak"

Variables

This section is empty.

Functions

func AbsPaths

func AbsPaths(rootPath string, relPaths []string) []string

AbsPaths prepends to all paths in relPaths the passed rootPath.

func BackupFile

func BackupFile(filepath string) error

BackupFile renames a file to <OldName><FileBackupSuffix>.

func DirsExist

func DirsExist(paths ...string) error

DirsExist runs DirExists for multiple paths.

func FileExists

func FileExists(path string) bool

FileExists returns true if path exist and is a file

func FileGlob

func FileGlob(pattern string) ([]string, error)

FileGlob resolves the pattern to absolute file paths. Files are resolved in the same way then filepath.Glob() does, with 2 Exceptions: - it also supports '**' to match files and directories recursively, - it only returns paths to files, no directory paths, If a globPath doesn't match any files an empty []string is returned and error is nil

func FileReadLine

func FileReadLine(path string) (string, error)

FileReadLine reads the first line from a file

func FileSize

func FileSize(path string) (int64, error)

FileSize returns the size of a file in Bytes

func FindFileInParentDirs

func FindFileInParentDirs(startPath, filename string) (string, error)

FindFileInParentDirs finds a file in startPath or its parent directories. The function starts looking for a file called filename in startPath and then checks recursively its parent directories. It returns the absolute path of the first match. If it reaches the root directory without finding the file it returns os.ErrNotExist.

func FindFilesInSubDir

func FindFilesInSubDir(searchDir, filename string, maxdepth int) ([]string, error)

FindFilesInSubDir returns all directories that contain filename that are in searchDir. The function descends up to maxdepth levels of directories below searchDir

func IsDir

func IsDir(path string) (bool, error)

IsDir returns true if the path is a directory. If the directory does not exist, the error from os.Stat() is returned.

func IsFile

func IsFile(path string) (bool, error)

IsFile returns true if path is a file. If the path does not exist an error is returned

func IsRegularFile

func IsRegularFile(path string) (bool, error)

IsRegularFile returns true if path is a regular file. If the directory does not exist, the error from os.Stat() is returned.

func Mkdir

func Mkdir(path string) error

Mkdir creates recursively directories

func PathsJoin

func PathsJoin(rootPath string, relPaths []string) []string

PathsJoin returns a list where all paths in relPaths are prefixed with rootPath

func SameFile

func SameFile(a, b string) (bool, error)

SameFile calls os.Samefile(), if one of the files does not exist, the error from os.Stat() is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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