home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / MNLDOS.ZIP / src / osgenfld.c < prev    next >
C/C++ Source or Header  |  2004-07-11  |  864b  |  32 lines

  1. /* $Id: osgenfld.c,v 1.2 2004/07/11 09:29:14 ozzmosis Exp $ */
  2.  
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5.  
  6. /* make an absolute path from given relative path */
  7. /* src is supposed to specify an existing directory name    */
  8. #define FUNCNAME "[generic] os_fulldir"
  9. int os_fulldir(char *dst, const char *src, size_t bufsiz)
  10. {
  11.     char tmp[MYMAXPATH];
  12.     struct stat st;
  13.  
  14.     Debug1("called with src='%s'\n", src);
  15.     strcpy(tmp, src);
  16.     os_remove_slash(tmp);
  17.     Debug1("after removing slash: '%s'\n", tmp);
  18.     if (os_fullpath(dst, tmp, bufsiz) != 0)
  19.     {
  20.         Debug("os_fullpath failed!\n");
  21.         return -1;
  22.     }
  23.     Debug1("doing stat on %s\n", dst);
  24.     if (stat(dst, &st) != 0)
  25.     {
  26.         Debug("stat failed!\n");
  27.         return -1;
  28.     }
  29.     Debug1("st_mode is now %o\n", st.st_mode);
  30.     return ((st.st_mode & S_IFMT) == S_IFDIR) ? 0 : -1;
  31. }
  32.