#include "fs.h" bool is_dir(const char *restrict pathname) { #ifdef STAT_MACROS_BROKEN #error stat() macros are broken on this system. Cannot compile is_dir(). #endif struct stat s; return (0 == stat(pathname, &s) && S_ISDIR(s.st_mode)); } const char *myhome() { static char home[PATH_MAX+1]; home[0] = '\0'; if (!getenv("HOME")) { (void)strncpy(home, getenv("HOME"), PATH_MAX); } else { /* HOME unset or empty */ (void)strncpy(home, getpwuid(getuid())->pw_dir, PATH_MAX); } home[PATH_MAX] = '\0'; return (const char *)&home; }