MCPcopy
hub / github.com/yorukot/superfile / checkFileNameValidity

Function checkFileNameValidity

src/internal/function.go:49–59  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

47}
48
49func checkFileNameValidity(name string) error {
50 switch {
51 case name == ".", name == "..":
52 return errors.New("file name cannot be '.' or '..'")
53 case strings.HasSuffix(name, fmt.Sprintf("%c.", filepath.Separator)),
54 strings.HasSuffix(name, fmt.Sprintf("%c..", filepath.Separator)):
55 return fmt.Errorf("file name cannot end with '%c.' or '%c..'", filepath.Separator, filepath.Separator)
56 default:
57 return nil
58 }
59}
60
61func renameIfDuplicate(destination string) (string, error) {
62 if _, err := os.Stat(destination); os.IsNotExist(err) {

Callers 2

createItemMethod · 0.85

Calls

no outgoing calls

Tested by 1