Forum: Ruby Find.find() doesn't work with broken symlinks

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B199c6556fec872d272086be15c5e4ab?d=identicon&s=25 Robert La ferla (rlaferla)
on 2007-03-26 23:19
(Received via mailing list)
Find.find() seems to filter out broken symlinks.  I was hoping to use it
to get a recursive list of files in directory so I could run various
tests on each file (like whether or not a symlink points to a valid
file)

What can I use instead of Find.find()?  Is there a better way?

   def testsymlinks(srcpath)
      Find.find(srcpath) do |path|
         if File.symlink?(path)
            begin
               File.stat(path)
      rescue Exception => e
               $stderr.puts "The symlink " + path + " does not point to
a valid file.  Please check that you have all your network volumes
mounted."
               exit(-1)
            end
         end
      end
   end
F8185f446010846108684a3397a29a6b?d=identicon&s=25 chopper (Guest)
on 2007-03-26 23:39
(Received via mailing list)
Is there a Rails specific list?  I tried subscribing to '
rails@lists.rubyonrails.org' but haven't been able to get a response.

- chopper
C40020a47c6b625af6422b5b1302abaf?d=identicon&s=25 Stefano Crocco (crocco)
on 2007-03-26 23:43
(Received via mailing list)
Alle lunedì 26 marzo 2007, robertlaferla@comcast.net ha scritto:
>                File.stat(path)
>       rescue Exception => e
>                $stderr.puts "The symlink " + path + " does not point to a
> valid file.  Please check that you have all your network volumes mounted."
> exit(-1)
>             end
>          end
>       end
>    end

Are you sure of this? I tried a small setup (made a directory, created a
file
and made a symlink to it, then removed the file) and it works. Find.find
passes the broken symlink to the block and File.stat raises a SystemCall
error (Errno::ENOENT). I'm running ruby 1.8.6 on gentoo linux.

Stefano
Ac0085dae0703db56ad7f8cb9e1798ba?d=identicon&s=25 Phillip Gawlowski (Guest)
on 2007-03-27 00:04
(Received via mailing list)
chopper wrote:
> Is there a Rails specific list?  I tried subscribing to '
> rails@lists.rubyonrails.org' but haven't been able to get a response.
>
> - chopper
>

http://www.rubyonrails.org/community

--
Phillip "CynicalRyan" Gawlowski

Eek! That was supposed to be My Special Law, _MY_ special law, I tell
you!

T/
This topic is locked and can not be replied to.