mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
Initial commit
This commit is contained in:
22
lib/utils/io.dart
Normal file
22
lib/utils/io.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'dart:io';
|
||||
|
||||
extension FSExt on FileSystemEntity {
|
||||
Future<void> deleteIfExists() async {
|
||||
if (await exists()) {
|
||||
await delete();
|
||||
}
|
||||
}
|
||||
|
||||
int get size {
|
||||
if (this is File) {
|
||||
return (this as File).lengthSync();
|
||||
} else if(this is Directory){
|
||||
var size = 0;
|
||||
for(var file in (this as Directory).listSync()){
|
||||
size += file.size;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user