From: Eric Christopherson Date: 2013-07-26T08:42:27+09:00 Subject: Re: waiting for a file to appear --089e0158ae38d4106004e25e9217 Content-Type: text/plain; charset=UTF-8 On Thu, Jul 25, 2013 at 5:42 PM, Thomas Luedeke wrote: > Having trouble finding a sound method that doesn't break when waiting > for a file to appear. My initial approach was this: > > while File.exists?( "filename" ) == false > sleep( 5 ) > end > > This worked for a while, but doesn't seem to be robust. I then tried > this: > > until File.exists?( "filename" ) > sleep( 5 ) > end > > Which also doesn't seem to work. > > I'm running Ruby 1.8.7. Is there a better way to do this? > > -- > Posted via http://www.ruby-forum.com/. > > Each OS family has its own system-level way of notifying programs when files are added, removed, or changed. There are Ruby interfaces for the Windows, Linux, and OS X methods; perhaps one of these gems would be of use? For Windows: rb-fchange For Linux: rb-inotify For OS X: rb-fsevent --089e0158ae38d4106004e25e9217 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Thu, Jul 25, 2013 at 5:42 PM= , Thomas Luedeke <lists@ruby-forum.com> wrote:
Having trouble finding a sound method that doesn't bre= ak when waiting
for a file to appear. =C2=A0My initial approach was this:

while File.exists?( "filename" ) =3D=3D false
=C2=A0 =C2=A0sleep( 5 )
end

This worked for a while, but doesn't seem to be robust. =C2=A0I then tr= ied
this:

until File.exists?( "filename" )
=C2=A0 =C2=A0sleep( 5 )
end

Which also doesn't seem to work.

I'm running Ruby 1.8.7. Is there a better way to do this?

--
Posted via http://= www.ruby-forum.com/.

=C2=A0
Each OS family has it= s own system-level way of notifying programs when files are added, removed,= or changed. There are Ruby interfaces for the Windows, Linux, and OS X met= hods; perhaps one of these gems would be of use?

For Windows= : rb-fchange
For Linux: rb-inotify
For OS X: rb-fsevent
--089e0158ae38d4106004e25e9217--