(name string)
| 47 | } |
| 48 | |
| 49 | func 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 | |
| 61 | func renameIfDuplicate(destination string) (string, error) { |
| 62 | if _, err := os.Stat(destination); os.IsNotExist(err) { |
no outgoing calls