SceneGate / Yarhl

Framework for the implementation of format converters like game assets or media files
https://scenegate.github.io/Yarhl/
MIT License
60 stars 10 forks source link

🐛 Fix Position getter of uninitiliazed LazyFileStream returning 0 #211

Closed pleonex closed 1 month ago

pleonex commented 1 month ago

The getter of Position of a LazyFileStream (type used to open files for Nodes by default) was already returning always 0. There was already logic in place to keep the initial position set, and used when opening the file later, but it was not returned.

Quality check list

Acceptance criteria

Accessing Position of a lazy FileStream should return the previous assigned value without opening the Stream.

Follow-up work

N/A

Example

using var stream = new LazyFileStream(filePath, FileOpenMode.ReadWrite);
Assert.That(stream.Position, Is.EqualTo(0));

stream.Position = 0x42;
Assert.That(stream.BaseStream, Is.Null);
Assert.That(stream.Position, Is.EqualTo(0x42));