#if defined(WIN32) &&!defined(__CYGWIN__) #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 #define FILEUTILS_MAX_PATH_LENGTH 2048 #if defined(WIN32) &&!defined(__CYGWIN__) 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 = ".:"; #if defined(__CYGWIN__) static const char *s_default_dso_path = "/usr/lib/:/usr/local/lib/:"; #else static const char *s_default_dso_path = "/usr/lib/:/usr/local/lib/:"; #endif // __CYGWIN__ static char *s_filePath = ".:"; #endif #if defined(WIN32) &&!defined(__CYGWIN__) #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; WIN32_FIND_DATA data; HANDLE handle = FindFirstFile((dirName + "\\*").c_str(), &data); if (handle != INVALID_HANDLE_VALUE) { do { contents.push_back(data.cFileName); } while (FindNextFile(handle, &data) != 0); 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