9 // SourceDirSubdir takes a source and returns a tuple of the URL without
10 // the subdir and the URL with the subdir.
11 func SourceDirSubdir(src string) (string, string) {
12 // Calcaulate an offset to avoid accidentally marking the scheme
15 if idx := strings.Index(src, "://"); idx > -1 {
19 // First see if we even have an explicit subdir
20 idx := strings.Index(src[offset:], "//")
29 // Next, check if we have query parameters and push them onto the
31 if idx = strings.Index(subdir, "?"); idx > -1 {
40 // SubdirGlob returns the actual subdir with globbing processed.
42 // dst should be a destination directory that is already populated (the
43 // download is complete) and subDir should be the set subDir. If subDir
44 // is an empty string, this returns an empty string.
46 // The returned path is the full absolute path.
47 func SubdirGlob(dst, subDir string) (string, error) {
48 matches, err := filepath.Glob(filepath.Join(dst, subDir))
53 if len(matches) == 0 {
54 return "", fmt.Errorf("subdir %q not found", subDir)
58 return "", fmt.Errorf("subdir %q matches multiple paths", subDir)
61 return matches[0], nil