
On 8 April 2013 15:45, Hong Yang
I got "not exists ..." from
fileExists <- doesFileExist "~/blah_blah" if fileExists then print "exists ..." else print "not exists ..."
using the directory-1.1.0.2 package, when ~/blah_blah does exist.
When you type “~/blah_blah” in your shell, the *shell* will expand “~” to your home directory, so when you pass “~/foo” to a program, that program never sees “~/foo”, but “/home/user/foo”. In other words, “~/blah_blah” probably does *not* exist. What you probably should do is to find the user's home directory and prepend that to “blah_blah”. You can find a user's homedir by calling `getHomeDirectory` from `System.Directory`: Prelude System.Directory> homedir <- getHomeDirectory Prelude System.Directory> putStrLn $ homedir ++ "/blah_blah" /Users/ehamberg/blah_blah -- Erlend Hamberg ehamberg@gmail.com