TrackModified adds a file to the modified files list and stores its original content
(filePath string)
| 61 | |
| 62 | // TrackModified adds a file to the modified files list and stores its original content |
| 63 | func (ft *FileTracker) TrackModified(filePath string) { |
| 64 | absPath, err := filepath.Abs(filePath) |
| 65 | if err != nil { |
| 66 | absPath = filePath |
| 67 | } |
| 68 | |
| 69 | // Store original content if not already stored |
| 70 | if _, exists := ft.OriginalContent[absPath]; !exists { |
| 71 | if content, err := os.ReadFile(absPath); err == nil { |
| 72 | ft.OriginalContent[absPath] = content |
| 73 | fileTrackerLog.Printf("Tracking modified file: %s (stored %d bytes)", absPath, len(content)) |
| 74 | } else { |
| 75 | fileTrackerLog.Printf("Tracking modified file: %s (failed to store original: %v)", absPath, err) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | ft.ModifiedFiles = append(ft.ModifiedFiles, absPath) |
| 80 | } |
| 81 | |
| 82 | // GetAllFiles returns all tracked files (created and modified) |
| 83 | func (ft *FileTracker) GetAllFiles() []string { |