getFolderPath static method
获取指定类型的文件夹路径(带缓存)
Gets the folder path for the specified type (with caching).
Implementation
static String? getFolderPath(FolderType type, [StorageType? storageType]) {
// 先检查缓存
if (_folderCache.containsKey(type)) {
return _folderCache[type];
}
final basePath = StorageManager.getBasePath(storageType);
if (basePath == null) {
loge('getFolderPath: base path is null for $type');
return null;
}
final folderPath = '$basePath/${type.folderName}';
// 尝试创建文件夹
final result = FileUtil.createDirectory(folderPath);
if (result.success) {
_folderCache[type] = folderPath;
return folderPath;
} else {
loge('Failed to create folder $folderPath: ${result.error}');
return null;
}
}