Raynes / fs

File system utilities for Clojure.
453 stars 119 forks source link

[Suggestion] Add function to fix paths for different OS #91

Open vbauer opened 9 years ago

vbauer commented 9 years ago

I usually face a problem of incorrect paths or part of paths. To fix this, I use the following workaround:

(defn- fix-path [p]
  (if (not (nil? p))
    (if (.startsWith (System/getProperty "os.name") "Windows")
      (string/replace p "/" "\\")
      (string/replace p "\\" "/"))))

Is it possible to put something like this in fs library?

Raynes commented 9 years ago

(str (fs/file path))

On Tue, Apr 7, 2015 at 1:03 PM, Vladislav Bauer notifications@github.com wrote:

I usually face a problem of incorrect paths or part of paths. To fix this, I use the following workaround:

(defn fix-path [path]
  (if windows?
    (string/replace path "/" "\\")
    (string/replace path "\\" "/")))

Is it possible to put something like this in fs library?

Reply to this email directly or view it on GitHub: https://github.com/Raynes/fs/issues/91

vbauer commented 9 years ago

Thank you for fast response! Documentation fo file function says:

"If `path` is a period, replaces it with cwd and creates a new File object
   out of it and `paths`. Or, if the resulting File object does not constitute
   an absolute path, makes it absolutely by creating a new File object out of
   the `paths` and cwd."

Actually, my path is not path to the real file. It could be just a part of some non-existed path (for example for some configuration needs). I'm not sure that it will help me..