From 078162c665bfb7cbb481424acd7fe49772c8a194 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 29 Jan 2011 22:50:11 +0000 Subject: GOB: Add setExtension() svn-id: r55639 --- engines/gob/util.cpp | 17 +++++++++++++++++ engines/gob/util.h | 3 +++ 2 files changed, 20 insertions(+) (limited to 'engines/gob') diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index fe45adb702..889833ad47 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -518,6 +518,23 @@ void Util::deleteList(List *list) { delete list; } +char *Util::setExtension(char *str, const char *ext) { + char *dot = strrchr(str, '.'); + if (dot) + *dot = '\0'; + + strcat(str, ext); + return str; +} + +Common::String Util::setExtension(const Common::String &str, const Common::String &ext) { + const char *dot = strrchr(str.c_str(), '.'); + if (dot) + return Common::String(str.c_str(), dot - str.c_str()) + ext; + + return str + ext; +} + /* NOT IMPLEMENTED */ void Util::checkJoystick() { _vm->_global->_useJoystick = 0; diff --git a/engines/gob/util.h b/engines/gob/util.h index 6968db1a27..262bff0a7a 100644 --- a/engines/gob/util.h +++ b/engines/gob/util.h @@ -131,6 +131,9 @@ public: static void listDropFront(List *list); static void deleteList(List *list); + static char *setExtension(char *str, const char *ext); + static Common::String setExtension(const Common::String &str, const Common::String &ext); + Util(GobEngine *vm); protected: -- cgit v1.2.3