From 1a0d8964163effb1df6b10ae6943c2d54ca87091 Mon Sep 17 00:00:00 2001 From: BearOso Date: Mon, 7 Sep 2020 10:58:47 -0500 Subject: [PATCH] Add compat.cpp. --- compat.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 compat.cpp 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); + } +}