On Tue, Nov 19, 2013 at 10:02 AM, James Reeves <[email protected]>wrote: > > > I think in this case it's more a problem with the Java API, which the fs > library wraps. Until Java 7, I don't think relative path normalisation > existed in the core Java libraries. > > It didn't, and .toPath isn't in the 1.6 java.io.File class in particular. 1.6 gives you these options:
user=> (reduce #(File. %1 %2) ["one" "two" ".." "three"]) #<File one\two\..\three> user=> (.getCanonicalFile (reduce #(File. %1 %2) ["one" "two" ".." "three"])) #<File C:\Windows\System32\one\three> user=> (.getPath (reduce #(File. %1 %2) ["one" "two" ".." "three"])) "one\\two\\..\\three" Of these only getCanonicalFile normalizes, but it also makes it absolute, treating it as having been relative to (on the Win32 box I tested it on) the OS system directory of all places. It *is* interesting that Ruby Pathname objects and Java File objects get printed very similarly by Ruby and Clojure, respectively. I assume that / will replace \ as the separator (and the base directory used by getCanonicalFile will vary) if the above is used on other operating systems' JVMs. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
