From b965b62436ac4376d452980671dd4ecded5edf97 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 7 Jun 2002 14:39:09 +0000 Subject: (remove_entry): Use DT_IS_DIR only if HAVE_STRUCT_DIRENT_D_TYPE is defined. --- src/remove.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/remove.c b/src/remove.c index 35a31d0aa..cd4ef6e45 100644 --- a/src/remove.c +++ b/src/remove.c @@ -611,7 +611,12 @@ prompt (char const *filename, struct rm_options const *x, return RM_OK; } -#define DT_IS_DIR(D) ((D)->d_type == DT_DIR) +#if HAVE_STRUCT_DIRENT_D_TYPE +# define DT_IS_DIR(D) ((D)->d_type == DT_DIR) +#else +/* Use this only if the member exists -- i.e., don't return 0. */ +# define DT_IS_DIR(D) do_not_use_this_macro +#endif #define DO_UNLINK(Filename, X) \ do \ @@ -675,13 +680,15 @@ remove_entry (char const *filename, struct rm_options const *x, #if ROOT_CAN_UNLINK_DIRS - /* If we don't already know whether FILENAME is a directory, - find out now. */ + /* If we don't already know whether FILENAME is a directory, find out now. + Then, if it's a non-directory, we can use unlink on it. */ if (is_dir == T_UNKNOWN) { +# if HAVE_STRUCT_DIRENT_D_TYPE if (dp) is_dir = DT_IS_DIR (dp) ? T_YES : T_NO; else +# endif { struct stat sbuf; if (lstat (filename, &sbuf)) -- cgit v1.2.3-54-g00ecf