removeTemporalFiles static method
Removes a list of temporary files from the file system.
This method iterates through the provided list of file paths and deletes each file if it exists. For security reasons, it only deletes files that are located within the designated temporary folder returned by getTemporalFolderPath.
The method is automatically skipped when:
- Running in mock mode (PdfCombiner.isMock is
true) - Running on web platforms
Parameters:
paths: List of absolute file paths to be removed
Implementation
static void removeTemporalFiles(List<String> paths) {
if (!PdfCombiner.isMock && !kIsWeb) {
for (final path in paths) {
// Ensure we only delete files within the designated temporary folder
if (path.startsWith(getTemporalFolderPath())) {
final file = File(path);
if (file.existsSync()) {
file.deleteSync();
}
}
}
}
}