mmp / pbrt-v2

Source code for the version of pbrt described in the second edition of "Physically Based Rendering"
http://pbrt.org
990 stars 343 forks source link

Search Path parsing problem #23

Closed mmp closed 10 years ago

mmp commented 10 years ago

(From mantis bug tracker)

There's a small function named SearchPath in dynload.cpp

static string SearchPath(const string &searchpath, const string &filename) { const char _start = searchpath.c_str(); const char end = start; while (_start) { while (end && *end != PBRT_PATH_SEP[0]) ++end; string component(start, end);

string fn = component + "/" + filename;

FILE _f = fopen(fn.c_str(), "r"); if (f) { fclose(f); return fn; } if (_end == PBRT_PATH_SEP[0]) ++end; start = end; } return "";

}

the problem is caused by ... ... string fn = component + "/" + filename; ... ...

The filename variable contains the name of the plugin, and the component variable contains one component of search paths, which are specified in PBRT_SEARCHPATH. When you have a path in PBRT_SEARCHPATH like

c:\pbrt-1.03

Suppose the content of filename variable is mitchell.dll, then the fn becomes

c:\pbrt-1.03/mitchell.dll

which can be correctly found.

But in windows system, when you have a space in the path name, you have to use " " to enclose the path, e.g.

"c:\Program Files\pbrt-1.03"

if you add a path like this to PBRT_SEARCHPATH, then the fn becomes

"c:\Program Files\pbrt-1.03"/mitchell.dll

which can NOT be found by the Windows system, though you have given the correct path and file name.

mmp commented 10 years ago

n/a for pbrt-v2 and beyond...