[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Detecting if a file is open
From: |
gOS |
Subject: |
Detecting if a file is open |
Date: |
Fri, 30 May 2008 12:53:34 -0700 (PDT) |
I'm wondering if there is a better way to do this.
fid = fopen('testfile.txt','w')
if(exist('fid'))
if(isequal(ferror(fid),''))
fclose(fid);
end
end
essenially, I'm assuming that if ferror is an empty string, then the file
needs closed. I'm using try catch error handling, and just want to make sure
everything is cleaned up properly before I exit the specific function. This
is useful when you want to work with a file without having to completely
shut down octave and restart it.
Is there a method that is more often used to tell if a file is open? Perhaps
more reliably? I just played around until I found this.
--
View this message in context:
http://www.nabble.com/Detecting-if-a-file-is-open-tp17566839p17566839.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Detecting if a file is open,
gOS <=