help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking whether a file exists


From: Primoz PETERLIN
Subject: Checking whether a file exists
Date: Fri, 7 Mar 2008 11:24:03 +0100

Hello everyone,

Time for another novice question...

What is the best way to check whether a data file exists (in order to avoid its accidental overwriting)?

1) The function exist() is supposed to return 2 "if the name (after appending `.m') is a function file in Octave's `path'", but it also returns 2 if a file is a data file in my search path, e.g., my current working directory. Is this the intended behaviour and something I should rely on, or is it just some side effect which can vanish in the next release of Octave. In the former case, the documentation should probably explicitely say so (Matlab documentation claims that exist(name) returns 2 "If name is an M-file on your MATLAB® search path. It also returns 2 when name is the full pathname to a file or the name of an ordinary file on your MATLAB search path. ").

2) stat() also does the job, but I believe it is not available in Matlab?

TIA, Primoz

reply via email to

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