|
|
@@ -1,6 +1,8 @@
|
|
|
|
|
|
import 'dart:io';
|
|
|
import 'dart:math';
|
|
|
+import 'package:convert/convert.dart';
|
|
|
+import 'package:crypto/crypto.dart';
|
|
|
import 'package:path/path.dart' as path;
|
|
|
import 'logger.dart';
|
|
|
|
|
|
@@ -44,6 +46,15 @@ String formatFileSize(int bytes) {
|
|
|
return ((bytes / pow(1024, i)).toStringAsFixed(2)) + ' ' + suffixes[i];
|
|
|
}
|
|
|
|
|
|
+// MD5
|
|
|
+Future<String> getFileMd5(String filePath) async {
|
|
|
+ final fileExists = File(filePath).existsSync();
|
|
|
+ if (!fileExists) throw FileSystemException("File does not exist", filePath);
|
|
|
+ final file = File(filePath);
|
|
|
+ final digest = await file.openRead().transform(md5).first;
|
|
|
+ return hex.encode(digest.bytes);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
createFolder(String folderPath) async {
|
|
|
// 创建文件夹
|