ValidatePathComponent will enforce os specific filename restrictions on a single path component.
(pathComponent string)
| 30 | |
| 31 | // ValidatePathComponent will enforce os specific filename restrictions on a single path component. |
| 32 | func ValidatePathComponent(pathComponent string) error { |
| 33 | // https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits |
| 34 | if len(pathComponent) > pathComponentMaxLength { |
| 35 | return errors.Join(ErrInvalidPath, errInvalidPathTooLong) |
| 36 | } |
| 37 | |
| 38 | if strings.TrimSpace(pathComponent) == "" { |
| 39 | return errors.Join(ErrInvalidPath, errInvalidPathEmpty) |
| 40 | } |
| 41 | |
| 42 | if err := validatePlatformSpecific(pathComponent); err != nil { |
| 43 | return errors.Join(ErrInvalidPath, err) |
| 44 | } |
| 45 | |
| 46 | return nil |
| 47 | } |
searching dependent graphs…