package archiver import ( "path/filepath" "strings" ) func getGlobRoot(path string) string { // Pfad säubern und Laufwerksbuchstaben trennen cleanedPath := filepath.Clean(path) volume := filepath.VolumeName(cleanedPath) // Erfasst Laufwerksbuchstaben wie "C:" // Pfad ohne Volume-Name splitten remainingPath := strings.TrimPrefix(cleanedPath, volume) pathSplit := strings.Split(remainingPath, string(filepath.Separator)) // Suche nach erstem "*" in den Pfadsegmenten for i, split := range pathSplit { if strings.Contains(split, "*") { // Falls ein Volume-Name vorhanden ist, füge es korrekt hinzu if len(volume) > 0 { volumeRoot := volume + string(filepath.Separator) return filepath.Join(append([]string{volumeRoot}, pathSplit[:i]...)...) } return filepath.Join(pathSplit[:i]...) } } // Wenn kein "*" gefunden wurde, gib den gesamten Pfad zurück return cleanedPath }