changeset 10169:06bd6e57f889

use rmdir module from gnulib
author John W. Eaton <jwe@octave.org>
date Thu, 21 Jan 2010 01:49:36 -0500
parents 37150167a72a
children 1dffc8b2fca7
files ChangeLog bootstrap.conf liboctave/ChangeLog liboctave/Makefile.am liboctave/file-ops.cc liboctave/lo-cutils.c liboctave/lo-utils.h liboctave/rmdir.c
diffstat 8 files changed, 22 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jan 21 01:09:42 2010 -0500
+++ b/ChangeLog	Thu Jan 21 01:49:36 2010 -0500
@@ -1,3 +1,7 @@
+2010-01-21  John W. Eaton  <jwe@octave.org>
+
+	* bootstrap.conf (gnulib_modules): Include rmdir in the list.
+
 2010-01-21  John W. Eaton  <jwe@octave.org>
 
 	* bootstrap.conf (gnulib_modules): Include c-strcase in the list.
--- a/bootstrap.conf	Thu Jan 21 01:09:42 2010 -0500
+++ b/bootstrap.conf	Thu Jan 21 01:49:36 2010 -0500
@@ -27,6 +27,7 @@
   lstat
   mkdir
   mkfifo
+  rmdir
   stat
   strftime
   times
--- a/liboctave/ChangeLog	Thu Jan 21 01:09:42 2010 -0500
+++ b/liboctave/ChangeLog	Thu Jan 21 01:49:36 2010 -0500
@@ -1,3 +1,11 @@
+2010-01-21  John W. Eaton  <jwe@octave.org>
+
+	* lo-cutils.c (octave_rmdir): New function.
+	* lo-utils.h: Provide decl.
+	* file-ops.cc (file_ops::rmdir): Call octave_rmdir.
+	* Makefile.am (LIBOCTAVE_C_SOURCES): Remove rmdir.c from the list.
+	* rmdir.c: Delete.
+
 2010-01-21  John W. Eaton  <jwe@octave.org>
 
 	* Makefile.am (LIBOCTAVE_C_SOURCES): Remove strcasecmp.c and
--- a/liboctave/Makefile.am	Thu Jan 21 01:09:42 2010 -0500
+++ b/liboctave/Makefile.am	Thu Jan 21 01:49:36 2010 -0500
@@ -464,7 +464,6 @@
   randmtzig.c \
   randpoisson.c \
   rename.c \
-  rmdir.c \
   strptime.c \
   tempnam.c \
   tempname.c
--- a/liboctave/file-ops.cc	Thu Jan 21 01:09:42 2010 -0500
+++ b/liboctave/file-ops.cc	Thu Jan 21 01:49:36 2010 -0500
@@ -291,17 +291,13 @@
 
   int status = -1;
 
-#if defined (HAVE_RMDIR)
-  status = ::rmdir (name.c_str ());
+  status = octave_rmdir (name.c_str ());
 
   if (status < 0)
     {
       using namespace std;
       msg = ::strerror (errno);
     }
-#else
-  msg = NOT_SUPPORTED ("rmdir");
-#endif
 
   return status;
 }
--- a/liboctave/lo-cutils.c	Thu Jan 21 01:09:42 2010 -0500
+++ b/liboctave/lo-cutils.c	Thu Jan 21 01:49:36 2010 -0500
@@ -92,6 +92,12 @@
 #endif
 
 OCTAVE_API int
+octave_rmdir (const char *name)
+{
+  return rmdir (name);
+}
+
+OCTAVE_API int
 octave_strcasecmp (const char *s1, const char *s2)
 {
   return strcasecmp (s1, s2);
--- a/liboctave/lo-utils.h	Thu Jan 21 01:09:42 2010 -0500
+++ b/liboctave/lo-utils.h	Thu Jan 21 01:49:36 2010 -0500
@@ -54,6 +54,8 @@
 extern "C" OCTAVE_API void octave_qsort (void *base, size_t n, size_t size,
 			      int (*cmp) (const void *, const void *));
 
+extern "C" OCTAVE_API int octave_rmdir (const char *name);
+
 extern "C" OCTAVE_API char *oct_strptime (const char *buf, const char *format,
 			       struct tm *tm);
 
--- a/liboctave/rmdir.c	Thu Jan 21 01:09:42 2010 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/* rmdir.c -- BSD compatible remove directory function for System V
-   Copyright (C) 1988, 1990 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301 USA.  */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifndef HAVE_RMDIR
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#include <sys/stat.h>
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-#ifdef STAT_MACROS_BROKEN
-#undef S_ISDIR
-#endif
-
-#if !defined(S_ISDIR) && defined(S_IFDIR)
-#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#endif
-
-#include "safe-stat.h"
-
-/* rmdir adapted from GNU tar.  */
-
-/* Remove directory DPATH.
-   Return 0 if successful, -1 if not.  */
-
-int
-rmdir (dpath)
-     char *dpath;
-{
-  int cpid, status;
-  struct stat statbuf;
-
-  if (SAFE_STAT (dpath, &statbuf) != 0)
-    return -1;			/* errno already set */
-
-  if (!S_ISDIR (statbuf.st_mode))
-    {
-      errno = ENOTDIR;
-      return -1;
-    }
-
-  cpid = fork ();
-  switch (cpid)
-    {
-    case -1:			/* cannot fork */
-      return -1;		/* errno already set */
-
-    case 0:			/* child process */
-      execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
-      _exit (1);
-
-    default:			/* parent process */
-
-      /* Wait for kid to finish.  */
-
-      while (wait (&status) != cpid)
-	/* Do nothing.  */ ;
-
-      if (status & 0xFFFF)
-	{
-
-	  /* /bin/rmdir failed.  */
-
-	  errno = EIO;
-	  return -1;
-	}
-      return 0;
-    }
-}
-
-#endif