xfs

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDirPerm  fs.FileMode = 0755 // drwxr-xr-x
	DefaultFilePerm fs.FileMode = 0644 // -rw-r--r--
)

Variables

This section is empty.

Functions

func CleanSlashPath

func CleanSlashPath(path string) string

CleanSlashPath returns clean and slash path.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Otherise, attempt to create a hard link between the two files. If that fails, copy the file contents from src to dst.

func Dir

func Dir(path string) string

Dir returns all but the last element of path, typically the path's directory. The result is a clean and slash path.

func Exists

func Exists(path string) (bool, error)

Exists returns whether the given file or directory exists

func GenCSVBooknamePattern

func GenCSVBooknamePattern(dir, bookName string) string

func GetDirectParentDirName

func GetDirectParentDirName(path string) string

GetDirectParentDirName returns the name of the direct parent directory of the given path. E.g.: "/parent/to/file.txt" -> "to".

func HasSubdirPrefix

func HasSubdirPrefix(path string, subdirs []string) bool

HasSubdirPrefix returns whether the given path has the given prefix.

func IsSamePath

func IsSamePath(leftPath, rightPath string) bool

IsSamePath checks if two paths are same based on clean slash path.

func Join

func Join(elem ...string) string

Join joins any number of path elements into a clean and slash path.

func ParseCSVBooknamePatternFrom

func ParseCSVBooknamePatternFrom(filename string) (string, error)

func ParseCSVFilenamePattern

func ParseCSVFilenamePattern(filename string) (bookName, sheetName string, err error)

func RangeFilesByFormat

func RangeFilesByFormat(dir string, fmt format.Format, callback func(bookPath string) error) error

RangeFilesByFormat traveses the given directory with the given format, and invoke the given callback for each file.

func Rel

func Rel(basepath string, targetpath string) (string, error)

Rel returns relative clean slash path.

func RewriteSubdir

func RewriteSubdir(path string, subdirRewrites map[string]string) string

RewriteSubdir replaces path's subdir part with the given subdirs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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