wrowe 2002/12/11 23:01:52
Modified: file_io/unix filestat.c
Log:
switch {case} and default: are probably better for handling this case.
Is anyone aware of a platform where S_IFxxx # isn't available, yet
S_ISxxx(#) is?
Revision Changes Path
1.58 +20 -16 apr/file_io/unix/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/filestat.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- filestat.c 22 Sep 2002 19:26:41 -0000 1.57
+++ filestat.c 12 Dec 2002 07:01:51 -0000 1.58
@@ -60,24 +60,28 @@
static apr_filetype_e filetype_from_mode(mode_t mode)
{
- apr_filetype_e type = APR_NOFILE;
+ apr_filetype_e type;
- if (S_ISREG(mode))
- type = APR_REG;
- if (S_ISDIR(mode))
- type = APR_DIR;
- if (S_ISCHR(mode))
- type = APR_CHR;
- if (S_ISBLK(mode))
- type = APR_BLK;
- if (S_ISFIFO(mode))
- type = APR_PIPE;
- if (S_ISLNK(mode))
- type = APR_LNK;
-#if !defined(BEOS) && defined(S_ISSOCK)
- if (S_ISSOCK(mode))
- type = APR_SOCK;
+ switch (type & S_IFMT) {
+ case S_IFREG:
+ type = APR_REG; break;
+ case S_IFDIR:
+ type = APR_DIR; break;
+ case S_IFLNK:
+ type = APR_LNK; break;
+ case S_IFCHR:
+ type = APR_CHR; break;
+ case S_IFBLK:
+ type = APR_BLK; break;
+ case S_IFFIFO:
+ type = APR_PIPE; break;
+#if !defined(BEOS) && defined(S_IFSOCK)
+ case S_IFSOCK:
+ type = APR_SOCK; break;
#endif
+ default:
+ type = APR_NOFILE;
+ }
return type;
}