diff --git a/lib/consts.dart b/lib/consts.dart index 4d3223e..d47d699 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -1,3 +1,3 @@ class Constants { - static const VERSION = "1.2.090324+0325"; + static const VERSION = "1.2.112524+1156"; } diff --git a/lib/nbt/Stream.dart b/lib/nbt/Stream.dart index bab2522..409e3bd 100644 --- a/lib/nbt/Stream.dart +++ b/lib/nbt/Stream.dart @@ -214,9 +214,21 @@ class ByteLayer { Future writeToFile(String filePath) async { final file = File(filePath); - if (file.existsSync()) - file.deleteSync(); // Ensure we flush the file to 0 bytes - await file.writeAsBytes(bytes); + try { + if (file.existsSync()) + file.deleteSync(); // Ensure we flush the file to 0 bytes + } catch (E) { + // If it fails then it fails, just fail silently, writing should still succeed. + } + + var rac = await file.open(mode: FileMode.write); + + for (var byte in bytes) { + await rac.writeByte(byte); + } + + await rac.flush(); + await rac.close(); } Future readFromFile(String filePath) async { @@ -227,7 +239,11 @@ class ByteLayer { return; } - _byteBuffer = await file.readAsBytes(); + RandomAccessFile rac = await file.open(mode: FileMode.read); + var length = await rac.length(); + _byteBuffer = await rac.read(length); + await rac.close(); + resetPosition(); } diff --git a/pubspec.yaml b/pubspec.yaml index 9778621..37fef95 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: libac_dart description: "Aria's Creations code library" -version: 1.2.090324+0325 +version: 1.2.112524+1156 homepage: "https://zontreck.com"