Yes, the path separator is O/S dependent: user> (import '(java.io File)) java.io.File user> (reduce #(File. %1 %2) ["one" "two" ".." "three"]) #<File one/two/../three> user> (.getCanonicalFile (reduce #(File. %1 %2) ["one" "two" ".." "three"])) #<File /Developer/workspace/worldsingles/ws/model/clojure/worldsingles/one/three> user> (.getPath (reduce #(File. %1 %2) ["one" "two" ".." "three"])) "one/two/../three"
Note that .getCanonicalFile renders the file path relative to the directory in which the REPL's JVM instance was started. Sean On Tue, Nov 19, 2013 at 7:02 PM, Cedric Greevey <cgree...@gmail.com> wrote: > On Tue, Nov 19, 2013 at 10:02 AM, James Reeves <ja...@booleanknot.com> > 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 clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > 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 clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.