diff src/load-save.cc @ 4844:9f7ef92b50b0

[project @ 2004-04-02 17:26:53 by jwe]
author jwe
date Fri, 02 Apr 2004 17:26:54 +0000
parents 62f2fb593455
children a9cfb8b37759
line wrap: on
line diff
--- a/src/load-save.cc	Fri Apr 02 14:54:20 2004 +0000
+++ b/src/load-save.cc	Fri Apr 02 17:26:54 2004 +0000
@@ -306,6 +306,13 @@
 {
   load_save_format retval = LS_UNKNOWN;
 
+  // If the file doesn't exist do nothing
+  std::ifstream file_exist (fname.c_str ());
+  if (file_exist)
+    file_exist.close ();
+  else
+    return LS_UNKNOWN;
+
 #ifdef HAVE_HDF5
   // check this before we open the file
   if (H5Fis_hdf5 (fname.c_str ()) > 0)
@@ -722,19 +729,26 @@
 	{
 	  i++;
 
-	  hdf5_ifstream hdf5_file (fname.c_str ());
-
-	  if (hdf5_file.file_id >= 0)
+	  // If the file doesn't exist do nothing
+	  std::ifstream file (fname.c_str (), std::ios::in);
+	  if (file)
 	    {
-	      retval = do_load (hdf5_file, orig_fname, force, format,
-				flt_fmt, list_only, swap, verbose,
-				argv, i, argc, nargout);
+	      file.close ();
+	      
+	      hdf5_ifstream hdf5_file (fname.c_str ());
 
-	      hdf5_file.close ();
+	      if (hdf5_file.file_id >= 0)
+		{
+		  retval = do_load (hdf5_file, orig_fname, force, format,
+				    flt_fmt, list_only, swap, verbose,
+				    argv, i, argc, nargout);
+
+		  hdf5_file.close ();
+		}
+	      else
+		error ("load: couldn't open input file `%s'",
+		       orig_fname.c_str ());
 	    }
-	  else
-	    error ("load: couldn't open input file `%s'",
-		   orig_fname.c_str ());
 	}
       else
 #endif /* HAVE_HDF5 */