File is deleted on write to ensure it does not continuously grow

This commit is contained in:
zontreck 2024-05-24 15:43:47 -07:00
parent 86ae7ad4aa
commit 0a5d99cd6f
3 changed files with 7 additions and 1 deletions

View file

@ -7,6 +7,10 @@ import 'impl/CompoundTag.dart';
class SnbtIo {
static void write(String file, CompoundTag tag) {
File handle = File(file);
if (handle.existsSync())
handle.deleteSync(); // Ensure we flush the file to 0 bytes
StringBuilder builder = StringBuilder();
Tag.writeStringifiedNamedTag(tag, builder, 0);
handle.writeAsString(builder.toString());

View file

@ -210,6 +210,8 @@ class ByteLayer {
Future<void> 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);
}

View file

@ -1,6 +1,6 @@
name: libac_dart
description: "Aria's Creations code library"
version: 1.0.21
version: 1.0.22
homepage: "https://zontreck.com"