Re: Checking if File Open

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Wed, 29 Jun 2005 14:11:12 -0700, Derek Parnell
<guest at RapidEuphoria.com> wrote:

>cklester wrote:
>> 
>> I've got a Win32Lib-based app. I do file replacement with it, but sometimes
>> the replacement doesn't work because the file is open. How can I determine up
>> front that a file is open or unavailable for replacement?
>
>  integer fn
>  object res
>  fn = open(filename, "r")
That just struck me as needing "w"; I could be wrong.
>  if fn = -1 then
>     -- file is open and locked or it is not there. 
>     res = dir(filename)
>     if equal(res, -1) = 0 then
>         -- file is missing
>     else
>         -- file is locked
>     end if
And I also thought:
   else
	close(fn)
	return [w32]True
>  end if
  return [w32]False

All Untested; I trust ck will report back results of any experiments.

Regards,
Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu