help-octave
[Top][All Lists]
Advanced

[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 11:05:52 -0400

On  2-Jun-2008, David Bateman wrote:

| John W. Eaton wrote:
| > On  2-Jun-2008, gOS wrote:
| >
| > | Except that unwind_protect is not compatible with Matlab, correct?
| > | Maintaining 2 separate scripts to do the exact same thing so that I can
| > | differentiate between try/catch and unwind_protect is not only 
unacceptable,
| > | its bad coding practice and leads to maintainability issues.
| >
| > Until the very latest Matlab release, Matlab had no way to do the
| > equivalent of unwind_protect.  Now, they have of course chosen to
| > implement something that sort of does the same thing, but in a
| > completely different way.  There has been some discussion of this
| > feature on the lists already, if you are intersted in helping out.
| >   
| To do it matlab's way we need the new OOP code of matlab introduced in
| 2008a in Octave and create and object with a destructor with the
| unwind_protect code.. If you really have to have the matlab compatible
| way of doing it then something like the thread
| 
| http://www.cae.wisc.edu/pipermail/octave-maintainers/2008-March/006503.html
| 
| is an approximation of the matlab onCleanup function.

But also note that if you want "Matlab compatibility" for cleanup
functions, then you are restricting your Matlab users to the latest
2008a release of Matlab...

I think the cleanup function idea (or unwind protect) is the cleanest
way to do what you want, but for the particular case of deciding
whether a file is open, you might try using

  open_fds = fopen ('all');

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]