/* mkpath - ensure all directories in path exist Algorithm takes the pessimistic view and works top-down to ensure each directory in path exists, rather than optimistically creating the last element and working backwards.  */
static int mkpath(const char *path, mode_t mode)
/* mkpath - ensure all directories in path exist Algorithm takes the pessimistic view and works top-down to ensure each directory in path exists, rather than optimistically creating the last element and working backwards.  */
static int mkpath(const char *path, mode_t mode)
{
    if (sp != pp)  {
      *sp = '\0';
      status = do_mkdir(copypath, mode);
      *sp = '/';
    }
    pp = sp + 1;
  }
  if (status == 0) {
      status = do_mkdir(path, mode);
  }
  free(copypath);
  return status;
}