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

DataStreamFactory does not check if the file exists when opening for reading #135

Closed pleonex closed 3 years ago

pleonex commented 4 years ago

Describe the bug The method DataStreamFactory.FromFile doesn't behave as FileStream and it doesn't check if the file exists when opening one for reading. It will throw the exception later when the user tries to access to the data.

To Reproduce

  1. Call DataStreamFactory.FromFile(path, FileOpenMode.Read) where path points to a file that doesn't exist yet.
  2. No exception is thrown.
  3. Use the stream, a exception is thrown.

Expected behavior There is a FileNotFoundException as FileStream does in the method that creates the DataStream. The reason is that we use internally a LazyFileStream so we don't open the file immediately but still we should check that.

Additional context These are the cases where FileStream will throw an exception:

FileNotFoundException The file cannot be found, such as when mode is FileMode.Truncate or FileMode.Open, and the file specified by path does not exist. The file must already exist in these modes.

It should be applied to the modes Append and Read from FileOpenMode.

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version v3.1.0 :tada:

The release is available on: