メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

rmdir.c

解説を見る。
00001 /* rmdir.c -- BSD compatible remove directory function for System V
00002    Copyright (C) 1988, 1990 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 2, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software
00016    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.  */
00017 
00018 #ifdef HAVE_CONFIG_H
00019 #include <config.h>
00020 #endif
00021 
00022 #ifndef HAVE_RMDIR
00023 
00024 #ifdef HAVE_SYS_TYPES_H
00025 #include <sys/types.h>
00026 #endif
00027 #include <sys/stat.h>
00028 
00029 #include <errno.h>
00030 #ifndef errno
00031 extern int errno;
00032 #endif
00033 
00034 #ifdef STAT_MACROS_BROKEN
00035 #undef S_ISDIR
00036 #endif
00037 
00038 #if !defined(S_ISDIR) && defined(S_IFDIR)
00039 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
00040 #endif
00041 
00042 #include "safe-stat.h"
00043 
00044 /* rmdir adapted from GNU tar.  */
00045 
00046 /* Remove directory DPATH.
00047    Return 0 if successful, -1 if not.  */
00048 
00049 int
00050 rmdir (dpath)
00051      char *dpath;
00052 {
00053   int cpid, status;
00054   struct stat statbuf;
00055 
00056   if (SAFE_STAT (dpath, &statbuf) != 0)
00057     return -1;                  /* errno already set */
00058 
00059   if (!S_ISDIR (statbuf.st_mode))
00060     {
00061       errno = ENOTDIR;
00062       return -1;
00063     }
00064 
00065   cpid = fork ();
00066   switch (cpid)
00067     {
00068     case -1:                    /* cannot fork */
00069       return -1;                /* errno already set */
00070 
00071     case 0:                     /* child process */
00072       execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
00073       _exit (1);
00074 
00075     default:                    /* parent process */
00076 
00077       /* Wait for kid to finish.  */
00078 
00079       while (wait (&status) != cpid)
00080         /* Do nothing.  */ ;
00081 
00082       if (status & 0xFFFF)
00083         {
00084 
00085           /* /bin/rmdir failed.  */
00086 
00087           errno = EIO;
00088           return -1;
00089         }
00090       return 0;
00091     }
00092 }
00093 
00094 #endif

Wed Dec 29 11:52:18 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送