bilib

package
v1.66.4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package bilib provides common stuff for bisync and bisync_test

Package bilib provides common stuff for bisync and bisync_test Here it's got local file/directory helpers (nice to have in lib/file)

Package bilib provides common stuff for bisync and bisync_test

Index

Constants

View Source
const PermSecure = 0600

PermSecure is a Unix permission for a file accessible only by its owner

Variables

This section is empty.

Functions

func AppyTimeGlobs added in v1.62.1

func AppyTimeGlobs(s string, t time.Time) string

AppyTimeGlobs converts "myfile-{DateOnly}.txt" to "myfile-2006-01-02.txt"

func BasePath added in v1.62.1

func BasePath(ctx context.Context, workDir string, fs1, fs2 fs.Fs) string

BasePath joins the workDir with the SessionName, stripping {hexstring} suffix if necessary

func CanonicalPath

func CanonicalPath(remote string) string

CanonicalPath converts a remote to a suitable base file name

func CaptureOutput

func CaptureOutput(fun func()) []byte

CaptureOutput runs a function capturing its output.

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir copies a local directory

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies a local file

func CopyFileIfExists

func CopyFileIfExists(srcFile, dstFile string) error

CopyFileIfExists is like CopyFile but does not fail if source does not exist

func FileExists

func FileExists(file string) bool

FileExists returns true if the local file exists

func FsPath

func FsPath(f fs.Info) string

FsPath converts Fs to a suitable rclone argument

func HasHexString added in v1.62.1

func HasHexString(path string) bool

HasHexString returns true if path contains at least one canonical {hexstring} suffix

func IsLocalPath

func IsLocalPath(path string) bool

IsLocalPath returns true if its argument is a non-remote path. Empty string or a relative path will be considered local. Note: `c:dir` will be considered local on Windows but remote on Linux.

func ParseGlobs added in v1.62.1

func ParseGlobs(s string) (hasGlobs bool, substring string)

ParseGlobs determines whether a string contains {brackets} and returns the substring (including both brackets) for replacing substring is first opening bracket to last closing bracket -- good for {{this}} but not {this}{this}

func SaveList

func SaveList(list []string, path string) error

SaveList saves file name list in a text file

func SessionName

func SessionName(fs1, fs2 fs.Fs) string

SessionName makes a unique base name for the sync operation

func StripHexString added in v1.62.1

func StripHexString(path string) string

StripHexString strips the (first) canonical {hexstring} suffix

func TimeFormat added in v1.62.1

func TimeFormat(timeFormat string) string

TimeFormat converts a user-supplied string to a Go time constant, if possible

func TrimBrackets added in v1.62.1

func TrimBrackets(s string) string

TrimBrackets converts {{this}} to this

Types

type AliasMap added in v1.62.1

type AliasMap map[string]string

AliasMap comprises a pair of names that are not equal but treated as equal for comparison purposes For example, when normalizing unicode and casing This helps reduce repeated normalization functions, which really slow things down

func (AliasMap) Add added in v1.62.1

func (am AliasMap) Add(name1, name2 string)

Add adds new pair to the set, in both directions

func (AliasMap) Alias added in v1.62.1

func (am AliasMap) Alias(name1 string) string

Alias returns the alternate version, if any, else the original.

type Names

type Names map[string]interface{}

Names comprises a set of file names

func ToNames

func ToNames(list []string) Names

ToNames converts string slice to a set of names

func (Names) Add

func (ns Names) Add(name string)

Add adds new file name to the set

func (Names) Has

func (ns Names) Has(name string) bool

Has checks whether given name is present in the set

func (Names) NotEmpty

func (ns Names) NotEmpty() bool

NotEmpty checks whether set is not empty

func (Names) Save

func (ns Names) Save(path string) error

Save saves name set in a text file

func (Names) ToList

func (ns Names) ToList() []string

ToList converts name set to string slice

Jump to

Keyboard shortcuts

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