[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (317d46af556d23315078a8a466f0829e8032e123)



The branch, master has been updated
       via  317d46af556d23315078a8a466f0829e8032e123 (commit)
      from  c1f85a94d591c58ac0f9f6ea4d217f96d14a4d98 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/file.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 50 insertions(+), 11 deletions(-)


=================
 Commit Messages
=================

commit 317d46af556d23315078a8a466f0829e8032e123
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    file.c: c Attempt to handle failure of GetWorkingDirectory() and chdir()
    
    Report the error to the user if any GetWorkingDirectory or chdir call
    fails. Add attempts to change back to the original working directory
    on error paths.
    
    Ideally, these functions would be re-implemented to operate without
    changing the current working directory at all.

:100644 100644 aff5073... 8cbd95d... M	src/file.c

=========
 Changes
=========

commit 317d46af556d23315078a8a466f0829e8032e123
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    file.c: c Attempt to handle failure of GetWorkingDirectory() and chdir()
    
    Report the error to the user if any GetWorkingDirectory or chdir call
    fails. Add attempts to change back to the original working directory
    on error paths.
    
    Ideally, these functions would be re-implemented to operate without
    changing the current working directory at all.

diff --git a/src/file.c b/src/file.c
index aff5073..8cbd95d 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1151,17 +1151,36 @@ LoadNewlibFootprintsFromDir(char *libpath, char *toppath)
   /* Cache old dir, then cd into subdir because stat is given relative file names. */
   memset (subdir, 0, sizeof subdir);
   memset (olddir, 0, sizeof olddir);
-  GetWorkingDirectory(olddir); 
+  if (GetWorkingDirectory (olddir) == NULL)
+    {
+      Message (_("LoadNewlibFootprintsFromDir: Could not determine initial working directory\n"));
+      return 0;
+    }
+
   strcpy (subdir, libpath);
-  chdir(subdir);
-  GetWorkingDirectory(subdir);  /* subdir is abs path */
+  if (chdir (subdir))
+    {
+      ChdirErrorMessage (subdir);
+      return 0;
+    }
+
+  /* Determine subdir is abs path */
+  if (GetWorkingDirectory (subdir) == NULL)
+    {
+      Message (_("LoadNewlibFootprintsFromDir: Could not determine new working directory\n"));
+      if (chdir (olddir))
+        ChdirErrorMessage (olddir);
+      return 0;
+    }
 
   /* First try opening the directory specified by path */
   if ( (subdirobj = opendir (subdir)) == NULL )
-  {
+    {
       OpendirErrorMessage (subdir);
+      if (chdir (olddir))
+        ChdirErrorMessage (olddir);
       return 0;
-  }
+    }
 
   /* Get pointer to memory holding menu */
   menu = GetLibraryMenuMemory (&Library);
@@ -1221,7 +1240,8 @@ LoadNewlibFootprintsFromDir(char *libpath, char *toppath)
   }
   /* Done.  Clean up, cd back into old dir, and return */
   closedir (subdirobj);
-  chdir(olddir);
+  if (chdir (olddir))
+    ChdirErrorMessage (olddir);
   return n_footprints;
 }
 
@@ -1252,7 +1272,11 @@ ParseLibraryTree (void)
   /* Save the current working directory as an absolute path.
    * This fcn writes the abs path into the memory pointed to by the input arg.
    */
-  GetWorkingDirectory (working);
+  if (GetWorkingDirectory (working) == NULL)
+    {
+      Message (_("ParseLibraryTree: Could not determine initial working directory\n"));
+      return 0;
+    }
 
   /* Additional loop to allow for multiple 'newlib' style library directories 
    * called out in Settings.LibraryTree
@@ -1266,14 +1290,28 @@ ParseLibraryTree (void)
       /* start out in the working directory in case the path is a
        * relative path 
        */
-      chdir (working);
+      if (chdir (working))
+        {
+          ChdirErrorMessage (working);
+          free (libpaths);
+          return 0;
+        }
 
       /*
        * Next change to the directory which is the top of the library tree
        * and extract its abs path.
        */
-      chdir (toppath);
-      GetWorkingDirectory (toppath);
+      if (chdir (toppath))
+        {
+          ChdirErrorMessage (toppath);
+          continue;
+        }
+
+      if (GetWorkingDirectory (toppath) == NULL)
+        {
+          Message (_("ParseLibraryTree: Could not determine new working directory\n"));
+          continue;
+        }
 
 #ifdef DEBUG
       printf("In ParseLibraryTree, looking for newlib footprints inside top level directory %s ... \n", 
@@ -1316,7 +1354,8 @@ ParseLibraryTree (void)
     }
 
   /* restore the original working directory */
-  chdir (working);
+  if (chdir (working))
+    ChdirErrorMessage (working);
 
 #ifdef DEBUG
   printf("Leaving ParseLibraryTree, found %d footprints.\n", n_footprints);




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs