platform_unix.c
changeset 90 1b004ccf775b
parent 89 0befb9dfdee4
child 91 6db187bc77c7
equal deleted inserted replaced
89:0befb9dfdee4 90:1b004ccf775b
   522 } /* spawn_xdelta */
   522 } /* spawn_xdelta */
   523 
   523 
   524 
   524 
   525 char *get_current_dir(char *buf, size_t bufsize)
   525 char *get_current_dir(char *buf, size_t bufsize)
   526 {
   526 {
   527     return(getcwd(buf, bufsize));
   527     size_t buflen = 0;
       
   528     if (getcwd(buf, bufsize) == NULL)
       
   529         return(NULL);
       
   530 
       
   531     buflen = strlen(buf) + 1;
       
   532     if (buflen <= bufsize)
       
   533     {
       
   534         *buf = '\0';
       
   535         return(NULL);
       
   536     } /* if */
       
   537 
       
   538     if (buf[buflen - 2] != '/')
       
   539         strcat(buf, "/");
       
   540 
       
   541     return(buf);
   528 } /* get_current_dir */
   542 } /* get_current_dir */
   529 
   543 
   530 
   544 
   531 static void find_basedir(int *argc, char **argv)
   545 static void find_basedir(int *argc, char **argv)
   532 {
   546 {