// RootedPath returns a rooted path, e.g. "/foo/bar" as // opposed to "foo/bar". func RootedPath(elem ...string) string { … } // StripTrailingSeps trims trailing filepath separators from input. func StripTrailingSeps(s string) string { … } // StripLeadingSeps trims leading filepath separators from input. func StripLeadingSeps(s string) string { … } // PathSplit converts a file path to a slice of string. // If the path is absolute (if the path has a leading slash), // then the first entry in the result is an empty string. // Desired: path == PathJoin(PathSplit(path)) func PathSplit(incoming string) []string { … } // PathJoin converts a slice of string to a file path. // If the first entry is an empty string, then the returned // path is absolute (it has a leading slash). // Desired: path == PathJoin(PathSplit(path)) func PathJoin(incoming []string) string { … } // InsertPathPart inserts 'part' at position 'pos' in the given filepath. // The first position is 0. // // E.g. if part == 'PEACH' // // OLD : NEW : POS // -------------------------------------------------------- // {empty} : PEACH : irrelevant // / : /PEACH : irrelevant // pie : PEACH/pie : 0 (or negative) // /pie : /PEACH/pie : 0 (or negative) // raw : raw/PEACH : 1 (or larger) // /raw : /raw/PEACH : 1 (or larger) // a/nice/warm/pie : a/nice/warm/PEACH/pie : 3 // /a/nice/warm/pie : /a/nice/warm/PEACH/pie : 3 // // * An empty part results in no change. // // - Absolute paths get their leading '/' stripped, treated like // relative paths, and the leading '/' is re-added on output. // The meaning of pos is intentionally the same in either absolute or // relative paths; if it weren't, this function could convert absolute // paths to relative paths, which is not desirable. // // - For robustness (liberal input, conservative output) Pos values // that are too small (large) to index the split filepath result in a // prefix (postfix) rather than an error. Use extreme position values // to assure a prefix or postfix (e.g. 0 will always prefix, and // 9999 will presumably always postfix). func InsertPathPart(path string, pos int, part string) string { … } func IsHiddenFilePath(pattern string) bool { … } // Removes paths containing hidden files/folders from a list of paths func RemoveHiddenFiles(paths []string) []string { … }