2

I have search a long time but didn't find the answer yet.

I'm using RUBY scripts to copy some folders and contents from a Linux station to another one. Until now it has been done by calling Xcopy on windows (via system).

Now I have visibility on both linux station so I decided to do a regular copy via Fileutils.

My problem is that it copies sometimes link and not the objetct itself: E.G

drwxr-xr-x 2 lcs rme   512 Apr  8 16:50 .
drwxr-xr-x 3 lcs rme   512 Apr  8 16:49 ..
lrwxrwxrwx 1 lcs rme    67 Apr  8 16:50 FW123.h -> /rees/frme/pd/ccm_dbs1/frme/root/cache/source/#27/1681927
-rw-r--r-- 1 lcs rme 25968 Apr  8 16:50 FW123.o

I try several things but it never worked. In particular I tried to play with dereference_root option , but it didn't work.

do you have some clue? thanks

Robert K
  • 30,064
  • 12
  • 61
  • 79
ludelle
  • 78
  • 5
  • I think there should be a is_link function somewhere - then you can read the file and and use the linked version. – User Apr 08 '13 at 16:09
  • Hum, but I have a lot of file to copy so it could take very long time to do that. – ludelle Apr 08 '13 at 16:13
  • Try it out. I think there are not many symlinks. They are usually make by humans and not generated so they should be less. Sometimes you can find a "follow symlink" argument in some list directory functions. Would "copy directory and follow symlink with ruby" be a better title? then maybe more people find this. http://stackoverflow.com/questions/1237939/ruby-how-do-i-get-the-target-of-a-symlink – User Apr 08 '13 at 16:16
  • In fact there is a lot. it comes from a management configuration tools that is configured to work with link instead of file. A fast count give something greater than 1000. Most of them are a few Kb but some can go up to 10 Mo – ludelle Apr 09 '13 at 07:10

1 Answers1

2

You can try File.realpath(pathname) - that will resolve symlinks.

István Rábel
  • 462
  • 4
  • 13