Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filesystem - no function to create hard links? #41574

Closed
andyferris opened this issue Jul 14, 2021 · 9 comments · Fixed by #41639
Closed

Filesystem - no function to create hard links? #41574

andyferris opened this issue Jul 14, 2021 · 9 comments · Fixed by #41639
Labels
feature Indicates new feature / enhancement requests filesystem Underlying file system and functions that use it

Comments

@andyferris
Copy link
Member

Unless I missed it, it seems we don't have a way to create hard links in the filesystem. I was suprised because we use libuv and Node has fs.linkSync(existing_path, new_path) and friends. I'm guessing adding this might not be too difficult?

See also https://discourse.julialang.org/t/create-hard-links-in-julia-is-there-another-way-than-via-external-command-run/12908

@andyferris andyferris added filesystem Underlying file system and functions that use it feature Indicates new feature / enhancement requests labels Jul 14, 2021
@c42f
Copy link
Member

c42f commented Jul 14, 2021

A survey of other language APIs:

It would seem natural to add this as hardlink(target::AbstractString, link::AbstractString) in analogy to the current symlink (C++ has seen fit to call this "hard link" in their API). Presumably the extra features available in the python API (os fd's) could be supported by allowing file descriptor types for target and link, if necessary later.

@andyferris
Copy link
Member Author

Thanks Chris. Yeah I agree with that naming - hardlink should be a little more obvious in meaning than link would be.

(Though I personally always found the target and link terminology super confusing and always second-guess the ordering, even for ln)

@c42f
Copy link
Member

c42f commented Jul 14, 2021

a little more obvious in meaning than link would be.

Also I think it would be unfortunate to export a completely generic name like link from Base and assign it a very concrete and relatively uncommonly-used meaning.

Though I personally always found the target and link terminology super confusing and always second-guess the ordering, even for

You're not the only one!

It seems to me that existing is the more obvious name here (unfortunately... the target technically doesn't have to exist for symlink, with the possible exception of windows). There's also src and dst to consider, in analogy to cp() (and python's os.link) which I think could be even better. Perhaps a little less technically correct, but hopefully much more obvious:

hardlink(src::AbstractString, dst::AbstractString)

@StefanKarpinski
Copy link
Member

Does Windows support hardlinks?

@andyferris
Copy link
Member Author

Yes, they are supported in NTFS.

@StefanKarpinski
Copy link
Member

StefanKarpinski commented Jul 17, 2021

Ok then it seems sensible to have a hardlink(src, dst) function. I agree that the argument order can be confusing, but we may as well be consistent with the standard confusing order.

@barucden
Copy link
Contributor

It amounts to

  • creating a new function (jl_fs_hardlink?) that calls libuv,
  • creating (and exporting) a Julia function (hardlink(src, dst)) which calls the new function,
  • and adding tests,

right? I think I could do that if nobody's working on it already.

@andyferris
Copy link
Member Author

That sounds about right to me. I haven’t started working on it - thank you for offering!

@StefanKarpinski
Copy link
Member

Yes, that sounds right. I would mimic what's done for jl_fs_symlink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests filesystem Underlying file system and functions that use it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants