Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <dir.h>
  3. #include <string.h>
  4.  
  5. void
  6. fnmerge (char *path, const char *drive, const char *dir,
  7.          const char *name, const char *ext)
  8. {
  9.   *path = '\0';
  10.   if (drive && *drive)
  11.   {
  12.     path[0] = drive[0];
  13.     path[1] = ':';
  14.     path[2] = 0;
  15.   }
  16.   if (dir && *dir)
  17.   {
  18.     char last_dir_char = dir[strlen(dir) - 1];
  19.  
  20.     strcat(path, dir);
  21.     if (last_dir_char != '/' && last_dir_char != '\\')
  22.       strcat(path, strchr(dir, '\\') ? "\\" : "/");
  23.   }
  24.   if (name)
  25.     strcat(path, name);
  26.   if (ext && *ext)
  27.   {
  28.     if (*ext != '.')
  29.       strcat(path, ".");
  30.     strcat(path, ext);
  31.   }
  32. }
  33.