package wing import ( "fmt" "os" "path/filepath" "sort" ) // legacyDirs are the retired wiki/{concepts,entities,sources}/ layout, not wings. var legacyDirs = map[string]bool{"concepts": true, "entities": true, "sources": true} // KnownWings lists wiki// directories that contain at least one hall // subdirectory, sorted. The retired layout is not a wing. A missing wiki/ is // an error: an unreadable brain must not look like "no wings". func KnownWings(brainDir string) ([]string, error) { entries, err := os.ReadDir(filepath.Join(brainDir, "wiki")) if err != nil { return nil, fmt.Errorf("list wings: %w", err) } var out []string for _, e := range entries { if !e.IsDir() || legacyDirs[e.Name()] { continue } subs, err := os.ReadDir(filepath.Join(brainDir, "wiki", e.Name())) if err != nil { continue } for _, s := range subs { if s.IsDir() { out = append(out, e.Name()) break } } } sort.Strings(out) return out, nil }