function  b = file_exists(fname)

%FILE_EXISTS -- 1 if a file (or dir) with FNAME exists and 0 otherwise.
%
%  b = file_exists(fname)
%
%  FNAME is a string. The result is either 0 or 1.
%  The file is not opened or closed. The function DIR is used:
%    b = ~isempty(dir(fname))
%
%  Examples:
%    file_exists('mydata.mat')
%    file_exists('file_exists.m')
%    file_exists('C:\myexp\data\sbj01.mat')
%    file_exists('\users\mydir')
%
%  See also DIR, WHAT, LOAD, FOPEN, PARTIALPATH.

% Original coding by Alex Petrov, Ohio State University
% $Revision: 1.0 $  $Date: 2004/02/24 13:16 $
%
% Part of the utils toolbox version 1.1 for MATLAB version 5 and up.
% http://alexpetrov.com/softw/utils/
% Copyright (c) Alexander Petrov 1999-2006, http://alexpetrov.com
% Please read the LICENSE and NO WARRANTY statement in ../utils_license.m

b = ~isempty(dir(fname)) ;

%--- Return B
%%%%% End of file FILE_EXISTS.M