getDirectoryFileCount static method
- String dirPath
Counts the number of files in a directory.
This method:
- Retrieves the directory contents.
- Counts files ending with '.enc.ttl'.
- Handles errors gracefully.
Parameters:
dirPath
: The directory path to count files in.
Returns the number of files in the directory, or 0 if an error occurs.
Implementation
static Future<int> getDirectoryFileCount(String dirPath) async {
try {
// Get directory contents and count files.
final dirUrl = await getDirUrl(dirPath);
final resources = await getResourcesInContainer(dirUrl);
return resources.files
.where((f) => f.endsWith('.enc.ttl') || f.endsWith('.ttl'))
.length;
} catch (e) {
// debugPrint('Error counting files in directory: $e');
return 0;
}
}