#ifdef WIN32 #include #include #include #elif !defined(macintosh) // UNIX #include #include #endif #include #include #include #include #include #include #include #include #include using namespace osg; using namespace osgDB; // follows is definition of strdup for compatibility under mac, // However, I'd prefer to migrate all the findFindInPath tools to use // std::string's and then be able to remove the following definition. // My objective is to minimize the number of platform #ifdef's as they // are source of potential bugs and developer confusion. #ifdef macintosh #ifndef strdup inline static char* strdup(const char *src); inline static char* strdup(const char *src) { char *ret = (char *) std::malloc(std::strlen(src) +1); if(!ret) return NULL; return std::strcpy(ret, src); } #endif #endif #ifdef WIN32 char *PathDelimitor = ";"; static const char *s_default_file_path = ".;"; static const char *s_default_dso_path = "C:/Windows/System/;"; static char *s_filePath = ".;"; #elif macintosh char *PathDelimitor = " "; static const char *s_default_file_path = ":"; static const char *s_default_dso_path = ":"; static char *s_filePath = ":"; #elif __sgi char *PathDelimitor = ":"; static const char *s_default_file_path = ".:"; static const char *s_default_dso_path = "/usr/lib32/:/usr/local/lib32/"; static char *s_filePath = ".:"; #else char *PathDelimitor = ":"; static const char *s_default_file_path = ".:"; static const char *s_default_dso_path = "/usr/lib/:/usr/local/lib/:"; static char *s_filePath = ".:"; #endif #if defined (WIN32) #define F_OK 4 #endif static bool s_filePathInitialized = false; void osgDB::initFilePath( void ) { char *ptr; if( (ptr = getenv( "OSGFILEPATH" )) ) { notify(DEBUG_INFO) << "osgDB::Init("< #include osgDB::DirectoryContents osgDB::getDirectoryContents(const std::string& dirName) { osgDB::DirectoryContents contents; struct _finddata_t data; long handle = _findfirst((dirName + "\\*").c_str(), &data); if (handle != -1) { do { contents.push_back(data.name); } while (_findnext(handle, &data) != -1); _findclose(handle); } return contents; } #elif !defined(macintosh) // UNIX #include osgDB::DirectoryContents osgDB::getDirectoryContents(const std::string& dirName) { osgDB::DirectoryContents contents; DIR *handle = opendir(dirName.c_str()); if (handle) { dirent *rc; while((rc = readdir(handle))!=NULL) { contents.push_back(rc->d_name); } closedir(handle); } return contents; } #endif