cleanupTempFiles method
Cleans up temporary and backup files.
Removes temporary files created during the generation process to keep the file system clean.
Parameters:
tempFiles: List of temporary file paths to removebackupFiles: List of backup file paths to remove
Returns the number of files successfully cleaned up.
Implementation
int cleanupTempFiles(List<String> tempFiles, List<String> backupFiles) {
var cleanedCount = 0;
final allFilesToClean = [...tempFiles, ...backupFiles];
for (final filePath in allFilesToClean) {
try {
if (exists(filePath)) {
delete(filePath);
cleanedCount++;
}
} catch (e) {
print('Warning: Failed to cleanup $filePath: $e');
}
}
return cleanedCount;
}