The only "modern Clojure" methods I'm aware of for checking for the existence of a file are the Java method (.exists (io/file filename-string)), or using something like the fs library: https://github.com/Raynes/fs
I'm surprised if the if (io/file path-to-session-fie) always returns false in your code example, because (io/file "string") returns a Java File object even if there is no such file, and Clojure if evaluates that as true, not false. Andy On Oct 25, 2012, at 3:21 PM, larry google groups wrote: > So, again, I'm trying to use Clojure to rebuild a PHP site. Right now I need > the Clojure code to read the PHP session files. In the below function, I have > a println that shows me that the path points to a file that really does > exist. And yet this if() clause seems to always return false. > > (defn does-session-exist? [session-id] > (let [path-to-session-file (str "/var/lib/php5/sess_" session-id)] > (println path-to-session-file) > (if (io/file path-to-session-file) > true > false))) > > "io" is an alias: > > (:require [clojure.string :as st] > [clojure.java.io :as io] > [clojure.data.json :as json] > [who-is-logged-in.memory_display :as who]) > > > I look here and see that the old monolithic Clojure contrib had an "exists" > function: > > http://clojuredocs.org/clojure_contrib/clojure.contrib.java-utils/file > > I see this example: > > (. (clojure.contrib.java-utils/file "...") exists) > > I'd like to do that but I don't know how with the modern clojure.java.io. > > I know I can use Java File objects, which has a similar "exists" method, but > I wonder if there is any modern Clojure equivalent? -- 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
