func getFilesWithSameName(fileName string, referenceTime time.Time) ([]File, error) {
var files []File
// Walk through the files and directories in the current directory and its subdirectories
err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
// Check if the file name matches the specified fileName and if it meets the time criteria
if info.Name() == fileName && (referenceTime.IsZero() || info.ModTime().After(referenceTime)) {
fullPath, err := filepath.Abs(path)
if err != nil {
return err
}
files = append(files, File{
Name: info.Name(),
IsFolder: info.IsDir(),
ModifiedTime: info.ModTime().Format(time.RFC3339),
FullPath: fullPath,
})
}
return nil
})
if err != nil {
return nil, err
}
return files, nil
}