diff options
Diffstat (limited to 'engines/director/util.cpp')
-rw-r--r-- | engines/director/util.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/engines/director/util.cpp b/engines/director/util.cpp index dbd1cd351f..cf7e122cd5 100644 --- a/engines/director/util.cpp +++ b/engines/director/util.cpp @@ -105,4 +105,41 @@ Common::String *toLowercaseMac(Common::String *s) { return res; } +Common::String convertPath(Common::String &path) { + if (path.empty()) + return path; + + if (!path.contains(':')) { + return path; + } + + if (path[0] != ':') { + warning("convertPath: unsupported absolute path '%s'", path.c_str()); + + return path; + } + + Common::String res; + int idx = 0; + + if (path.hasPrefix(":::")) { + res = "../"; + idx = 3; + } else { + res = "./"; + idx = 1; + } + + while (idx != path.size()) { + if (path[idx] == ':') + res += '/'; + else + res += path[idx]; + + idx++; + } + + return res; +} + } // End of namespace Director |