From 6adb14a7027c8d54827093c83fc80694d71fb6a7 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 20 Jun 2018 19:21:48 +0200 Subject: Fix missing finalization of instruments on load. Fix relative instrument filenames according to the drumkit file. Make drumkit creator create version 2.0 drumkits. Reduce missing refs file to a warning. --- src/path.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/path.cc') diff --git a/src/path.cc b/src/path.cc index c2e7910..993f9a6 100644 --- a/src/path.cc +++ b/src/path.cc @@ -40,7 +40,7 @@ std::string getPath(const std::string& file) #ifdef __MINGW32__ char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; - _splitpath(file.c_str(), drive, dir, NULL, NULL); + _splitpath(file.c_str(), drive, dir, nullptr, nullptr); path = std::string(drive) + dir; #else // POSIX @@ -51,3 +51,22 @@ std::string getPath(const std::string& file) return path; } + +std::string getFile(const std::string& file) +{ + std::string path; + +#ifdef __MINGW32__ + char fname[_MAX_FNAME]; + char ext[_MAX_EXT]; + _splitpath(file.c_str(), nullptr, nullptr, fname, ext); + path = std::string(fname) + "." + ext; +#else + // POSIX + char* buffer = strdup(file.c_str()); + path = basename(buffer); + free(buffer); +#endif + + return path; +} -- cgit v1.2.3