spm_existfile.m 1.0 KB

123456789101112131415161718192021222324252627
  1. function s = spm_existfile(filename)
  2. % Check if a file exists on disk - a compiled routine
  3. % FORMAT s = spm_existfile(filename)
  4. % filename - filename (can also be a relative or full pathname to a file)
  5. % s - logical scalar, true if the file exists and false otherwise
  6. %__________________________________________________________________________
  7. %
  8. % This compiled routine is equivalent to:
  9. % >> s = exist(filename,'file') == 2;
  10. % and was written for speed purposes. The differences in behaviour is that
  11. % spm_existfile does not look in MATLAB's search path.
  12. %__________________________________________________________________________
  13. % Copyright (C) 2008-2012 Wellcome Trust Centre for Neuroimaging
  14. % Guillaume Flandin
  15. % $Id: spm_existfile.m 4901 2012-09-05 15:10:48Z guillaume $
  16. %-This is merely the help file for the compiled routine
  17. %error('spm_existfile.c not compiled - see Makefile')
  18. persistent runOnce
  19. if isempty(runOnce)
  20. warning('spm_existfile is not compiled for your platform.');
  21. runOnce = true;
  22. end
  23. s = exist(filename,'file') > 0;