gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
741 stars 93 forks source link

Refactor File I/O handling #817

Open nightm4re94 opened 7 months ago

nightm4re94 commented 7 months ago

Make our File handling more robust by replacing the current mix of java.lang.String and java.io.File objects with the more recent java.nio.file.Path api. The need for many helper methods in the FileUtilities class would no longer be given when using the java.nio.file.Files class, e.g. for copying or reading files. Especially in the utiLITI editor, this change would simplify many things. We'd have to make sure that File handling uses Paths exclusively, but things like Maps of currently loaded Spritesheets should still use String values (file names) as the map's keyset rather than Path objects.

Furthermore, we could improve the way we load image files by adopting the ImageIO utility methods for image loading in conjunction with the Path api for path processing.

I have originally started a branch for the conversion but progress has stalled and I got lost.

Some references to the java NIO2 Path api: https://blogs.oracle.com/javamagazine/post/java-nio-nio2-buffers-channels-async-future-callback?source=:em:nw:mt::::RC_WWMK200429P00043C00073:NSL400304995 https://blogs.oracle.com/javamagazine/post/path-files-input-output?source=:em:nw:mt::::RC_WWMK200429P00043C00073:NSL400304995 https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html https://www.baeldung.com/java-nio-2-file-api https://howtodoinjava.com/java/nio/how-to-define-path-in-java-nio/

SushmitaGoswami commented 2 months ago

Can I contribute to this? If yes, do I need to first assign it on my name first? Thanks so much!

nightm4re94 commented 2 months ago

Gladly, thank you!