-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreflect.go
More file actions
53 lines (44 loc) · 1.07 KB
/
reflect.go
File metadata and controls
53 lines (44 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"time"
)
func latestChatLog() string {
entries, err := os.ReadDir(kOutputDir)
if err != nil {
if *figs.Bool(kDebug) {
_, _ = fmt.Fprintf(os.Stderr, "Error reading directory %s: %v\n", kOutputDir, err)
}
return ""
}
var latestFile string
var latestModTime time.Time
for _, entry := range entries {
if entry.IsDir() {
continue
}
filename := entry.Name()
if strings.HasPrefix(filename, "chatlog.") && strings.HasSuffix(filename, ".md") {
fullPath := filepath.Join(kOutputDir, filename)
fileInfo, err := entry.Info()
if err != nil {
if *figs.Bool(kDebug) {
_, _ = fmt.Fprintf(os.Stderr, "Error getting file info for %s: %v\n", fullPath, err)
}
continue
}
modTime := fileInfo.ModTime()
if latestFile == "" || modTime.After(latestModTime) {
latestFile = fullPath
latestModTime = modTime
}
}
}
if latestFile == "" && *figs.Bool(kDebug) {
_, _ = fmt.Fprintf(os.Stderr, "No summary files found in directory %s\n", kOutputDir)
}
return latestFile
}