Directory copying using hard links?

M

Michael Schuerig

Is there an "official" way of recursively copying directories so that
individual files are hard-linked (if possible)? FileUtils has methods
for creating single hard links (#ln) as well as for recursive copying
(#cp_r). What's missing is the combination, essentially a call to

cp -al src dest

However, I'm wary of using this instead of FileUtils.cp_r(src, dest) as
the semantics are different. #cp_r makes a copy with path dest of a
directory with path src. In contrast, cp -a src dest copies src into(!)
dest. Now, File.dirname(File.expand_path(dest)) gives me the parent
directory, but I'm simply not sure whether it works as intended in all
cases.

Any suggestions?

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top