* dont't require direntry->d_type; this should help the Solaris build.

also, some cleanups
This commit is contained in:
Dirk-Jan C. Binnema
2010-12-11 13:52:03 +02:00
parent a0069702ba
commit d14727c7a8
6 changed files with 201 additions and 128 deletions

View File

@ -27,7 +27,7 @@
#include <wordexp.h> /* for shell-style globbing */
#include <stdlib.h>
/* hopefully, the should get us a sane PATH_MAX */
/* hopefully, this should get us a sane PATH_MAX */
#include <limits.h>
/* not all systems provide PATH_MAX in limits.h */
#ifndef PATH_MAX
@ -274,4 +274,28 @@ mu_util_create_writeable_fd (const char* filename, const char* dir,
return fd;
}
unsigned char
mu_util_get_dtype_with_lstat (const char *path)
{
struct stat statbuf;
g_return_val_if_fail (path, DT_UNKNOWN);
if (lstat (path, &statbuf) != 0) {
g_warning ("stat failed on %s: %s",
path, strerror(errno));
return DT_UNKNOWN;
}
/* we only care about dirs, regular files and links */
if (S_ISREG (statbuf.st_mode))
return DT_REG;
else if (S_ISDIR (statbuf.st_mode))
return DT_DIR;
else if (S_ISLNK (statbuf.st_mode))
return DT_LNK;
return DT_UNKNOWN;
}