Hi. Don't know if this is the right place but I was using the babashka/fs library yesterday and managed to confuse myself with the create-sym-link function.
The function itself looks like this:
(defn create-sym-link
"Create a soft link from path to target."
[path target]
(Files/createSymbolicLink
(as-path path)
(as-path target)
(make-array FileAttribute 0)))
while the java.nio function it calls is documented as
java.nio.file.Files/createSymbolicLink
[link target attrs]
Creates a symbolic link to a target (optional operation).
@param link the path of the symbolic link to create @param target the target of the symbolic link
@param attrs the array of attributes to set atomically when creating the symbolic link
@return the path to the symbolic link
so the usage is
(create-sym-link new-file-link where-the-link-points-to)
But target in my mind becomes ambiguous when mixed with path. Maybe because I'm not native English? Point 'at' vs point 'from' maybe?
Now that I've debugged it I understand. But I did mess up at first. Maybe because I was writing a script that moves a file from A to B, then create a new link A that points to B, basically centralizing my config files because after making complex config files I needed to version control them.
What I did not understand yesterday was if the path or the target was the canonical file, or the 'main node' so to speak.
In bash the links show up as a nice arrow, so pretty clear what 'points to' is used for in retrospect.
somefile -> /a/path/somefile becomes path -> target
The https://www.man7.org/linux/man-pages/man1/ln.1.html documents the os linking tool ln as
ln - make links between files
ln [OPTION]... [-T] TARGET LINK_NAME
...
In the 1st form, create a link to TARGET with the name LINK_NAME.
which makes it clear that target means the target is the 'source', or the actual file. But the argument ordering is opposite that of the create-sym-link function, so maybe that's why I was confused because of remembering creating links manually in bash?
Sorry for complaining. But maybe this helps someone else in the future.A valid point of confusion, imo. The decision about the order of arguments in create-sym-link is that it's the same order as the Java API.
The names of the Java API are link and target . Do you think it would be less confusing if I changed path to link? Probably so?
Probably, yes. Just irks me a bit that it breaks the nice consistency of naming where you have ~82 path parameters in the fs namespace.... But maybe its the little mind speaking..
✅
https://github.com/babashka/fs/commit/eba0df764dc7c50db3f1f61f05d620af097c54ae
Awesome! I remember falling into the same trap and making a mess :)