diff --git a/compat.cpp b/compat.cpp new file mode 100644 index 00000000..c2f2b402 --- /dev/null +++ b/compat.cpp @@ -0,0 +1,63 @@ +void _splitpath(const char *path, char *drive, char *dir, char *fname, char *ext) +{ + char *slash = strrchr((char *)path, SLASH_CHAR); + char *dot = strrchr((char *)path, '.'); + + *drive = '\0'; + + if (dot && slash && dot < slash) + { + dot = 0; + } + + if (!slash) + { + *dir = '\0'; + strcpy(fname, path); + + if (dot) + { + fname[dot - path] = '\0'; + strcpy(ext, dot + 1); + } + else + { + *ext = '\0'; + } + } + else + { + strcpy(dir, path); + dir[slash - path] = '\0'; + strcpy(fname, slash + 1); + + if (dot) + { + fname[(dot - slash) - 1] = '\0'; + strcpy(ext, dot + 1); + } + else + { + *ext = '\0'; + } + } +} + +void _makepath(char *path, const char *drive, const char *dir, const char *fname, const char *ext) +{ + if (dir && *dir) + { + strcpy(path, dir); + strcat(path, "/"); + } + else + *path = '\0'; + + strcat(path, fname); + + if (ext && *ext) + { + strcat(path, "."); + strcat(path, ext); + } +}