From 68d33f39fa50eb98e43a3db89c3c28a2903c0ba3 Mon Sep 17 00:00:00 2001 From: nate smith Date: Mon, 1 Jul 2024 00:55:29 -0700 Subject: [PATCH] WIP geocities stuff --- geocities/main.go | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 geocities/main.go diff --git a/geocities/main.go b/geocities/main.go new file mode 100644 index 0000000..221f348 --- /dev/null +++ b/geocities/main.go @@ -0,0 +1,58 @@ +package main + +import ( + "fmt" + "os" + "path/filepath" + "sync" +) + +const p = "/home/vilmibm/geocities/UPPERCASE/geocities/YAHOOIDS" + +func main() { + userDirs := make(chan string) + var wg sync.WaitGroup + + walkFn := func(s string, d os.DirEntry, err error) error { + if err != nil { + return err + } + if !d.IsDir() { + return nil + } + + isUserDir, err := filepath.Match("/home/vilmibm/geocities/UPPERCASE/geocities/YAHOOIDS/?/?/*", s) + if err != nil { + return err + } + + if isUserDir { + userDirs <- s + } + + //if len(d.Name()) > 1 && d.IsDir() { + // fmt.Printf("%s %s\n", s, d.Name()) + //} + // TODO be able to tell when s is a full path (ie to a file for user) + // TODO sniff what kind of file full path points to + // TODO if text, read and append to file for that user + return nil + } + go func() { + err := filepath.WalkDir(p, walkFn) + close(userDirs) + if err != nil { + panic(err) + } + }() + for ud := range userDirs { + wg.Add(1) + go processUserDir(&wg, ud) + } + wg.Wait() +} + +func processUserDir(wg *sync.WaitGroup, ud string) { + defer wg.Done() + fmt.Printf("GONNA PROCESS %s\n", ud) +}