Skip to content

Refactor File I/O handling #817

Open
@nightm4re94

Description

@nightm4re94

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/

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions