Patches a bug in IOTools#getFileSize and #getDirectorySize on platforms with hard links which point to folders that no longer exist as a part of the base OS design (I am looking at you... windows)
This commit is contained in:
parent
ccb23fdf3d
commit
7c87ef444f
3 changed files with 40 additions and 30 deletions
|
@ -1,3 +1,3 @@
|
||||||
class Constants {
|
class Constants {
|
||||||
static const VERSION = "1.2.082424+0723";
|
static const VERSION = "1.2.082424+1243";
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,9 +221,11 @@ Future<int> getFileSize(String path,
|
||||||
if (verbose) await prnt("${trunc("\r> Checking size of file $path")}");
|
if (verbose) await prnt("${trunc("\r> Checking size of file $path")}");
|
||||||
/*final fileBytes = await File(path).readAsBytes();
|
/*final fileBytes = await File(path).readAsBytes();
|
||||||
int size = fileBytes.lengthInBytes;*/
|
int size = fileBytes.lengthInBytes;*/
|
||||||
|
try {
|
||||||
final size = await File(path).length();
|
final size = await File(path).length();
|
||||||
|
|
||||||
if (verbose) await prnt("${trunc("\r>> Size of file $path")} is $size bytes");
|
if (verbose)
|
||||||
|
await prnt("${trunc("\r>> Size of file $path")} is $size bytes");
|
||||||
|
|
||||||
if (cacheSize) {
|
if (cacheSize) {
|
||||||
FileInformationCache FIC = FileInformationCache.obtain();
|
FileInformationCache FIC = FileInformationCache.obtain();
|
||||||
|
@ -231,16 +233,21 @@ Future<int> getFileSize(String path,
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
} catch (E) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getDirectorySize(String path,
|
Future<int> getDirectorySize(String path,
|
||||||
{bool recursive = false,
|
{bool recursive = false,
|
||||||
bool cacheSize = false,
|
bool cacheSize = false,
|
||||||
bool verbose = false}) async {
|
bool verbose = false}) async {
|
||||||
|
try {
|
||||||
int totalSize = 0;
|
int totalSize = 0;
|
||||||
if (verbose) await prnt("\r${trunc("> Check dir size of $path")}");
|
if (verbose) await prnt("\r${trunc("> Check dir size of $path")}");
|
||||||
final entityList =
|
final entityList = await Directory(path)
|
||||||
await Directory(path).list(recursive: false, followLinks: true).toList();
|
.list(recursive: false, followLinks: true)
|
||||||
|
.toList();
|
||||||
|
|
||||||
await Future.forEach(entityList, (entity) async {
|
await Future.forEach(entityList, (entity) async {
|
||||||
if (entity is File) {
|
if (entity is File) {
|
||||||
|
@ -262,6 +269,9 @@ Future<int> getDirectorySize(String path,
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalSize;
|
return totalSize;
|
||||||
|
} catch (E) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> prnt(String text) async {
|
Future<void> prnt(String text) async {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: libac_dart
|
name: libac_dart
|
||||||
description: "Aria's Creations code library"
|
description: "Aria's Creations code library"
|
||||||
version: 1.2.082424+0723
|
version: 1.2.082424+1243
|
||||||
homepage: "https://zontreck.com"
|
homepage: "https://zontreck.com"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue