mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-11-28 05:00:26 +08:00
Adds the S3 `fileshare` implementation This also updates `wsh file cp` so it behaves more like `cp` for things like copying directories and directory entries. It's not meant to align with `cp` on everything, though. Our `wsh cp` will be recursive and will create intermediate directories by default. This also adds new aliases for `wsh view`: `wsh preview` and `wsh open` --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: sawka <mike@commandline.dev> Co-authored-by: Sylvia Crowe <software@oneirocosm.com>
37 lines
747 B
Go
37 lines
747 B
Go
package fspath
|
|
|
|
import (
|
|
pathpkg "path"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
// Separator is the path separator
|
|
Separator = "/"
|
|
)
|
|
|
|
func Dir(path string) string {
|
|
return pathpkg.Dir(ToSlash(path))
|
|
}
|
|
|
|
func Base(path string) string {
|
|
return pathpkg.Base(ToSlash(path))
|
|
}
|
|
|
|
func Join(elem ...string) string {
|
|
joined := pathpkg.Join(elem...)
|
|
return ToSlash(joined)
|
|
}
|
|
|
|
// FirstLevelDir returns the first level directory of a path and a boolean indicating if the path has more than one level.
|
|
func FirstLevelDir(path string) (string, bool) {
|
|
if strings.Count(path, Separator) > 0 {
|
|
path = strings.SplitN(path, Separator, 2)[0]
|
|
return path, true
|
|
}
|
|
return path, false
|
|
}
|
|
|
|
func ToSlash(path string) string {
|
|
return strings.ReplaceAll(path, "\\", Separator)
|
|
}
|