aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorEugene Sandulenko2017-03-29 08:35:33 +0200
committerEugene Sandulenko2017-03-29 08:35:33 +0200
commit1f5a57a54c4d70198b40c31dff49f4356821e403 (patch)
treef5dc723a35ffb4253c0c79210a39e544677327e8 /engines/director
parent581b2c84b83f7ab491f10b122662a1d6de62060f (diff)
downloadscummvm-rg350-1f5a57a54c4d70198b40c31dff49f4356821e403.tar.gz
scummvm-rg350-1f5a57a54c4d70198b40c31dff49f4356821e403.tar.bz2
scummvm-rg350-1f5a57a54c4d70198b40c31dff49f4356821e403.zip
DIRECTOR: Convert HFS file paths to Posix
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/lingo/lingo-funcs.cpp20
-rw-r--r--engines/director/util.cpp37
-rw-r--r--engines/director/util.h2
3 files changed, 50 insertions, 9 deletions
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp
index 0f2110d8f1..4c02bf6bad 100644
--- a/engines/director/lingo/lingo-funcs.cpp
+++ b/engines/director/lingo/lingo-funcs.cpp
@@ -30,6 +30,7 @@
#include "director/lingo/lingo.h"
#include "director/lingo/lingo-gr.h"
#include "director/sound.h"
+#include "director/util.h"
namespace Director {
@@ -180,6 +181,7 @@ void Lingo::func_goto(Datum &frame, Datum &movie) {
if (movie.type != VOID) {
movie.toString();
+ Common::String movieFilename = convertPath(*movie.u.s);
Common::String cleanedFilename;
bool fileExists = false;
@@ -187,30 +189,30 @@ void Lingo::func_goto(Datum &frame, Datum &movie) {
if (_vm->getPlatform() == Common::kPlatformMacintosh) {
Common::MacResManager resMan;
- for (const byte *p = (const byte *)movie.u.s->c_str(); *p; p++)
+ for (const byte *p = (const byte *)movieFilename.c_str(); *p; p++)
if (*p >= 0x20 && *p <= 0x7f)
cleanedFilename += (const char) *p;
- if (resMan.open(*movie.u.s)) {
+ if (resMan.open(movieFilename)) {
fileExists = true;
- cleanedFilename = *movie.u.s;
- } else if (!movie.u.s->equals(cleanedFilename) && resMan.open(cleanedFilename)) {
+ cleanedFilename = movieFilename;
+ } else if (!movieFilename.equals(cleanedFilename) && resMan.open(cleanedFilename)) {
fileExists = true;
}
} else {
Common::File file;
- cleanedFilename = *movie.u.s + ".MMM";
+ cleanedFilename = movieFilename + ".MMM";
- if (file.open(*movie.u.s)) {
+ if (file.open(movieFilename)) {
fileExists = true;
- cleanedFilename = *movie.u.s;
- } else if (!movie.u.s->equals(cleanedFilename) && file.open(cleanedFilename)) {
+ cleanedFilename = movieFilename;
+ } else if (!movieFilename.equals(cleanedFilename) && file.open(cleanedFilename)) {
fileExists = true;
}
}
if (!fileExists) {
- warning("Movie %s does not exist", movie.u.s->c_str());
+ warning("Movie %s does not exist", movieFilename.c_str());
return;
}
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
diff --git a/engines/director/util.h b/engines/director/util.h
index c31240052b..e5ce0f5355 100644
--- a/engines/director/util.h
+++ b/engines/director/util.h
@@ -34,6 +34,8 @@ char *numToCastNum(int num);
Common::String *toLowercaseMac(Common::String *s);
+Common::String convertPath(Common::String &path);
+
void processQuitEvent(); // events.cpp
} // End of namespace Director