Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed use of PATH_MAX (only used in searchpath expansion).

Added searchpath to regression test.
  • Loading branch information...
commit 2d346a02ca88d90b3866c4af6e17be52e73fdf9c 1 parent 5052077
Brent Burley authored
View
2  src/ptex/Makefile
@@ -9,7 +9,7 @@ endif
# DEBUG = -g -DDEBUG
DEBUG = -O2 -DNDEBUG
INCPATH = -I.
-DEFINES = -DPATH_MAX=256
+DEFINES =
CXXFLAGS = -Wall -pedantic -W -std=c++98 $(DEBUG) $(INCPATH) $(DEFINES) -fPIC
LFLAGS =
LIBS = -lm -lz -lpthread
View
14 src/ptex/PtexCache.cpp
@@ -334,17 +334,21 @@ PtexTexture* PtexReaderCache::get(const char* filename, Ptex::String& error)
// temporarily release cache lock while we open the file
cachelock.unlock();
- char tmppath[PATH_MAX+1];
+ std::string tmppath;
+ const char* pathToOpen = filename;
if (!_io) {
if (filename[0] != '/' && !_searchdirs.empty()) {
// file is relative, search in searchpath
+ tmppath.reserve(256); // minimize reallocs (will grow automatically)
bool found = false;
struct stat statbuf;
for (size_t i = 0, size = _searchdirs.size(); i < size; i++) {
- snprintf(tmppath, sizeof(tmppath), "%s/%s", _searchdirs[i].c_str(), filename);
- if (stat(tmppath, &statbuf) == 0) {
+ tmppath = _searchdirs[i];
+ tmppath += "/";
+ tmppath += filename;
+ if (stat(tmppath.c_str(), &statbuf) == 0) {
found = true;
- filename = tmppath;
+ pathToOpen = tmppath.c_str();
break;
}
}
@@ -356,7 +360,7 @@ PtexTexture* PtexReaderCache::get(const char* filename, Ptex::String& error)
}
}
}
- if (ok) ok = reader->open(filename, error);
+ if (ok) ok = reader->open(pathToOpen, error);
// reacquire cache lock
cachelock.lock();
View
1  src/ptex/PtexPlatform.h
@@ -79,7 +79,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
typedef __int64 FilePos;
#define fseeko _fseeki64
#define ftello _ftelli64
-#define PATH_MAX MAX_PATH
inline double log2(double x) {
return log(x) * 1.4426950408889634;
View
5 src/tests/rtest.cpp
@@ -101,7 +101,9 @@ void DumpMetaData(PtexMetaData* meta)
int main(int /*argc*/, char** /*argv*/)
{
Ptex::String error;
- PtexTexture* r = PtexTexture::open("test.ptx", error);
+ PtexPtr<PtexCache> c(PtexCache::create());
+ c->setSearchPath("foo/bar:.");
+ PtexPtr<PtexTexture> r(c->get("test.ptx", error));
if (!r) {
std::cerr << error.c_str() << std::endl;
@@ -153,6 +155,5 @@ int main(int /*argc*/, char** /*argv*/)
dh->release();
}
- r->release();
return 0;
}

0 comments on commit 2d346a0

Please sign in to comment.
Something went wrong with that request. Please try again.