Let's pass root_dir as token, rather than trying to guess it

This commit is contained in:
rdb 2009-12-27 15:34:44 +00:00
parent a53c0b1b59
commit bc055e2d9f

View File

@ -95,6 +95,7 @@ run_embedded(int read_offset, int argc, char *argv[]) {
token._value = NULL; token._value = NULL;
string keyword; string keyword;
string value; string value;
string root_dir;
while (true) { while (true) {
curchr = read.get(); curchr = read.get();
if (curchr == 0) { if (curchr == 0) {
@ -115,11 +116,13 @@ run_embedded(int read_offset, int argc, char *argv[]) {
token._value = value.c_str(); token._value = value.c_str();
_tokens.push_back(token); _tokens.push_back(token);
// Read out the width and height token // Read out the tokens that may interest us
if (keyword == "width") { if (keyword == "width") {
_win_width = atoi(value.c_str()); _win_width = atoi(value.c_str());
} else if (keyword == "height") { } else if (keyword == "height") {
_win_height = atoi(value.c_str()); _win_height = atoi(value.c_str());
} else if (keyword == "root_dir") {
root_dir = value;
} }
} }
curstr = ""; curstr = "";
@ -138,31 +141,6 @@ run_embedded(int read_offset, int argc, char *argv[]) {
read_offset = read.tellg(); read_offset = read.tellg();
read.close(); read.close();
// Find the root directory
Filename root_dir (f);
root_dir = Filename(root_dir.get_dirname());
#ifdef __APPLE__
root_dir = Filename(root_dir.get_dirname(), "Resources");
#endif
if (Filename(root_dir, "contents.xml").exists()) {
string path = root_dir.to_os_generic();
if (!path.empty() && path[0] != '/') {
// On Windows, a leading drive letter must be preceded by an
// additional slash.
path = "/" + path;
}
path = "file://" + path;
}
#if !defined(_WIN32) && !defined(__APPLE__)
else { // On Unix, we should try to find it in the share directory under the prefix.
root_dir = Filename(root_dir.get_dirname(), "share/" + f.get_basename());
if (Filename(root_dir, "contents.xml").exists()) {
string path = root_dir.to_os_generic();
path = "file://" + path;
}
}
#endif
// Initialize the plugin // Initialize the plugin
if (!P3D_initialize(P3D_API_VERSION, NULL, if (!P3D_initialize(P3D_API_VERSION, NULL,
_host_url.c_str(), _verify_contents, _this_platform.c_str(), _host_url.c_str(), _verify_contents, _this_platform.c_str(),