@@ -199,12 +199,11 @@ func NewFilesystem(fsType FilesystemType, uri string) Filesystem {
|
||||
func IsInternal(file string) bool {
|
||||
// fs cannot import config, so we hard code .stfolder here (config.DefaultMarkerName)
|
||||
internals := []string{".stfolder", ".stignore", ".stversions"}
|
||||
pathSep := string(PathSeparator)
|
||||
for _, internal := range internals {
|
||||
if file == internal {
|
||||
return true
|
||||
}
|
||||
if strings.HasPrefix(file, internal+pathSep) {
|
||||
if IsParent(file, internal) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,3 +77,15 @@ func WindowsInvalidFilename(name string) bool {
|
||||
// The path must not contain any disallowed characters
|
||||
return strings.ContainsAny(name, windowsDisallowedCharacters)
|
||||
}
|
||||
|
||||
func IsParent(path, parent string) bool {
|
||||
if len(parent) == 0 {
|
||||
// The empty string is the parent of everything except the empty
|
||||
// string. (Avoids panic in the next step.)
|
||||
return len(path) > 0
|
||||
}
|
||||
if parent[len(parent)-1] != PathSeparator {
|
||||
parent += string(PathSeparator)
|
||||
}
|
||||
return strings.HasPrefix(path, parent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user