Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
add normalized `.path()` to FileHandle #2617
It's a feature present both in core Java 7 lib (which is currently unsupported neither in libGDX nor on Android) [https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html#normalize%28%29] and in Apache Commons IO [http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FilenameUtils.html#normalize%28java.lang.String%29], and is a quite nice & simple feature. It makes the path more "canonical" by getting rid of e.g.
Currently we have to either convert the
add path normalizer to FileHandle
add normalized `.path()` to FileHandle
changed the title from
Dec 1, 2014
Sadly, no. Tried it already, it's a no-go. As e.g. http://docs.oracle.com/javase/7/docs/api/java/io/File.html#getAbsolutePath%28%29 & http://stackoverflow.com/questions/1099300/whats-the-difference-between-getpath-getabsolutepath-and-getcanonicalpath show clearly - the functionalities of absolute path and normalized path are quite distinct. Absolute path is usually normalized when generated by OS (although that's not guaranteed vs absolute paths, only canonical paths), but not every normalized path has to be absolute. Sometimes you need a relative, yet normalized path. That's the exact case I described here. Also, absolute paths are resolved in OS-dependent way. The function that guarantees a normalized path is http://docs.oracle.com/javase/7/docs/api/java/io/File.html#getCanonicalPath%28%29 - but it always returns an absolute path, so it can't be applied to paths that has to stay relative.
Having a normalizer to normalize relative paths is a completely valid use case - otherwise nobody would even care with creating a normalizer for paths IMO.
NB this is obviously an enhancement request, not a bug report.