Raynes / fs

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

no path join, or separator? #59

Closed acthp closed 11 years ago

acthp commented 11 years ago

I notice there are operations for splitting paths, but none for joining them. Also, the file separator is not exported (seems like it was in the first announcements of this lib?), so callers will have to independently import File to join paths.

Raynes commented 11 years ago
(fs/file "a" "path" "segment")
bitemyapp commented 11 years ago

:bomb: boom.

bitemyapp commented 11 years ago

Lets :bug: @amalloy all right now :dancers: :dancer: :dancers:

acthp commented 11 years ago

fs/file is not just doing a join. It's also doing cwd operations. I guess I can use io/file.

Raynes commented 11 years ago

Why does that matter? It'll have the same effect as io/file if cwd hasn't changed.

On Wed, Sep 18, 2013 at 1:16 PM, acthp notifications@github.com wrote:

fs/file is not just doing a join. It's also doing cwd operations. I guess I can use io/file.

Reply to this email directly or view it on GitHub: https://github.com/Raynes/fs/issues/59#issuecomment-24695673

acthp commented 11 years ago

No, that's incorrect.

cavm.cgdata=> (fs/file "one")
#<File /inside/home/craft/cavm/one>
cavm.cgdata=> (io/file "one")
#<File one>
Raynes commented 11 years ago

All it did was make the path absolute to the current working directory which is what would happen later when you need to actually do an operation or something, but fair enough. In any case, io/file and fs/file are the things one is meant to use to do what you want to do.

As for the separator bit, if it isn't exposed I'd take a pull request to add it.

acthp commented 11 years ago

It matters when working with abstract paths, for example when dealing with files that contain references to other files. I'm doing transforms on such files, not actually reading the files they point to. So if there's a relative reference like "../over/there", and it gets changed to an absolute reference on the filesystem, the file is now broken.

It's important to be able to normalize paths while doing this, however normalize-path also converts them to absolute references. More worrying, it looks like the underlying java call .getCanonicalFile also does this. I can work around it by prepending root, then removing it. Kinda clumsy.