[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Detecting if a file is open
From: |
John W. Eaton |
Subject: |
Re: Detecting if a file is open |
Date: |
Mon, 02 Jun 2008 09:24:02 -0400 |
On 2-Jun-2008, gOS wrote:
| Let me give you a specific example:
|
| function = foo(bar.txt)
|
| try
| fid = fopen(bar.txt)
| if(fid < 0)
| warning('file never opened)
| return;
| end
|
| % do a bunch of stuff with the file
|
| % ! an unforeseen error occurs here %
|
| % do more stuff with the file
|
| fclose(fid)
|
| catch
|
| % detect whether the file is still open (see original post)
|
| if ( fileIsOpen )
| fclose(fid)
| end
| end
You want unwind_protect, not try/catch.
jwe