| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #if 0 // defined(__APPLE__) |
|---|
| 14 | #include "FileUtils_Mac.cpp" // this is not functional yet -- fix! |
|---|
| 15 | #else |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | #if defined(WIN32) && !defined(__CYGWIN__) |
|---|
| 22 | #include <Io.h> |
|---|
| 23 | #include <Windows.h> |
|---|
| 24 | #include <Winbase.h> |
|---|
| 25 | #include <sys/types.h> |
|---|
| 26 | #include <sys/stat.h> |
|---|
| 27 | |
|---|
| 28 | #define F_OK 4 |
|---|
| 29 | #else // unix |
|---|
| 30 | #include <unistd.h> |
|---|
| 31 | #include <sys/types.h> |
|---|
| 32 | #include <sys/stat.h> |
|---|
| 33 | #endif |
|---|
| 34 | |
|---|
| 35 | #include <osg/Notify> |
|---|
| 36 | |
|---|
| 37 | #include <osgDB/FileUtils> |
|---|
| 38 | #include <osgDB/FileNameUtils> |
|---|
| 39 | #include <osgDB/Registry> |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | void osgDB::convertStringPathIntoFilePathList(const std::string& paths,FilePathList& filepath) |
|---|
| 43 | { |
|---|
| 44 | #if defined(WIN32) && !defined(__CYGWIN__) |
|---|
| 45 | char delimitor = ';'; |
|---|
| 46 | #else |
|---|
| 47 | char delimitor = ':'; |
|---|
| 48 | #endif |
|---|
| 49 | |
|---|
| 50 | if (!paths.empty()) |
|---|
| 51 | { |
|---|
| 52 | std::string::size_type start = 0; |
|---|
| 53 | std::string::size_type end; |
|---|
| 54 | while ((end = paths.find_first_of(delimitor,start))!=std::string::npos) |
|---|
| 55 | { |
|---|
| 56 | filepath.push_back(std::string(paths,start,end-start)); |
|---|
| 57 | start = end+1; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | filepath.push_back(std::string(paths,start,std::string::npos)); |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | bool osgDB::fileExists(const std::string& filename) |
|---|
| 66 | { |
|---|
| 67 | return access( filename.c_str(), F_OK ) == 0; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | osgDB::FileType osgDB::fileType(const std::string& filename) |
|---|
| 71 | { |
|---|
| 72 | #if 1 |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | struct stat fileStat; |
|---|
| 76 | if ( stat(filename.c_str(), &fileStat) != 0 ) |
|---|
| 77 | { |
|---|
| 78 | return FILE_NOT_FOUND; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | if ( fileStat.st_mode & S_IFDIR ) |
|---|
| 82 | return DIRECTORY; |
|---|
| 83 | else if ( fileStat.st_mode & S_IFREG ) |
|---|
| 84 | return REGULAR_FILE; |
|---|
| 85 | |
|---|
| 86 | return FILE_NOT_FOUND; |
|---|
| 87 | |
|---|
| 88 | #else |
|---|
| 89 | #if defined(WIN32) && !defined(__CYGWIN__) |
|---|
| 90 | struct _stat fileStat; |
|---|
| 91 | if ( _stat(filename.c_str(), &fileStat) != 0 ) |
|---|
| 92 | { |
|---|
| 93 | return FILE_NOT_FOUND; |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | if ( fileStat.st_mode & _S_IFDIR ) |
|---|
| 97 | return DIRECTORY; |
|---|
| 98 | else if ( fileStat.st_mode & _S_IFREG ) |
|---|
| 99 | return REGULAR_FILE; |
|---|
| 100 | |
|---|
| 101 | return FILE_NOT_FOUND; |
|---|
| 102 | |
|---|
| 103 | #else |
|---|
| 104 | struct stat fileStat; |
|---|
| 105 | |
|---|
| 106 | if(stat(filename.c_str(), &fileStat) == -1) |
|---|
| 107 | { |
|---|
| 108 | return FILE_NOT_FOUND; |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | if(S_ISREG(fileStat.st_mode)) |
|---|
| 112 | { |
|---|
| 113 | return REGULAR_FILE; |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | if(S_ISDIR(fileStat.st_mode)) |
|---|
| 117 | { |
|---|
| 118 | return DIRECTORY; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | return FILE_NOT_FOUND; |
|---|
| 122 | #endif |
|---|
| 123 | #endif |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | std::string osgDB::findFileInPath(const std::string& filename, const FilePathList& filepath,CaseSensitivity caseSensitivity) |
|---|
| 127 | { |
|---|
| 128 | if (filename.empty()) |
|---|
| 129 | return filename; |
|---|
| 130 | |
|---|
| 131 | if(fileExists(filename)) |
|---|
| 132 | { |
|---|
| 133 | osg::notify(osg::DEBUG_INFO) << "FindFileInPath(" << filename << "): returning " << filename << std::endl; |
|---|
| 134 | return filename; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | for(FilePathList::const_iterator itr=filepath.begin(); |
|---|
| 138 | itr!=filepath.end(); |
|---|
| 139 | ++itr) |
|---|
| 140 | { |
|---|
| 141 | std::string path = *itr + '/'+ filename; |
|---|
| 142 | osg::notify(osg::DEBUG_INFO) << "FindFileInPath() : trying " << path << " ...\n"; |
|---|
| 143 | if(fileExists(path)) |
|---|
| 144 | { |
|---|
| 145 | osg::notify(osg::DEBUG_INFO) << "FindFileInPath() : USING " << path << "\n"; |
|---|
| 146 | return path; |
|---|
| 147 | } |
|---|
| 148 | #ifndef WIN32 |
|---|
| 149 | |
|---|
| 150 | else if (caseSensitivity==CASE_INSENSITIVE) |
|---|
| 151 | { |
|---|
| 152 | std::string foundfile = findFileInDirectory(filename,*itr,CASE_INSENSITIVE); |
|---|
| 153 | if (!foundfile.empty()) return foundfile; |
|---|
| 154 | } |
|---|
| 155 | #endif |
|---|
| 156 | |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | return std::string(); |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | std::string osgDB::findDataFile(const std::string& filename,CaseSensitivity caseSensitivity) |
|---|
| 163 | { |
|---|
| 164 | if (filename.empty()) return filename; |
|---|
| 165 | |
|---|
| 166 | const FilePathList& filepath = Registry::instance()->getDataFilePathList(); |
|---|
| 167 | |
|---|
| 168 | std::string fileFound = findFileInPath(filename, filepath,caseSensitivity); |
|---|
| 169 | if (!fileFound.empty()) return fileFound; |
|---|
| 170 | |
|---|
| 171 | |
|---|
| 172 | std::string simpleFileName = getSimpleFileName(filename); |
|---|
| 173 | if (simpleFileName!=filename) |
|---|
| 174 | { |
|---|
| 175 | std::string fileFound = findFileInPath(simpleFileName, filepath,caseSensitivity); |
|---|
| 176 | if (!fileFound.empty()) return fileFound; |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | return std::string(); |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | std::string osgDB::findLibraryFile(const std::string& filename,CaseSensitivity caseSensitivity) |
|---|
| 184 | { |
|---|
| 185 | if (filename.empty()) |
|---|
| 186 | return filename; |
|---|
| 187 | |
|---|
| 188 | const FilePathList& filepath = Registry::instance()->getLibraryFilePathList(); |
|---|
| 189 | |
|---|
| 190 | std::string fileFound = findFileInPath(filename, filepath,caseSensitivity); |
|---|
| 191 | if (!fileFound.empty()) |
|---|
| 192 | return fileFound; |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | std::string simpleFileName = getSimpleFileName(filename); |
|---|
| 196 | if (simpleFileName!=filename) |
|---|
| 197 | { |
|---|
| 198 | std::string fileFound = findFileInPath(simpleFileName, filepath,caseSensitivity); |
|---|
| 199 | if (!fileFound.empty()) return fileFound; |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | return findFileInPath("osgPlugins/"+simpleFileName,filepath,caseSensitivity); |
|---|
| 205 | } |
|---|
| 206 | |
|---|
| 207 | std::string osgDB::findFileInDirectory(const std::string& fileName,const std::string& dirName,CaseSensitivity caseSensitivity) |
|---|
| 208 | { |
|---|
| 209 | bool needFollowingBackslash = false; |
|---|
| 210 | bool needDirectoryName = true; |
|---|
| 211 | osgDB::DirectoryContents dc; |
|---|
| 212 | |
|---|
| 213 | if (dirName.empty()) |
|---|
| 214 | { |
|---|
| 215 | dc = osgDB::getDirectoryContents("."); |
|---|
| 216 | needFollowingBackslash = false; |
|---|
| 217 | needDirectoryName = false; |
|---|
| 218 | } |
|---|
| 219 | else if (dirName=="." || dirName=="./" || dirName==".\\") |
|---|
| 220 | { |
|---|
| 221 | dc = osgDB::getDirectoryContents("."); |
|---|
| 222 | needFollowingBackslash = false; |
|---|
| 223 | needDirectoryName = false; |
|---|
| 224 | } |
|---|
| 225 | else |
|---|
| 226 | { |
|---|
| 227 | dc = osgDB::getDirectoryContents(dirName); |
|---|
| 228 | char lastChar = dirName[dirName.size()-1]; |
|---|
| 229 | if (lastChar=='/') needFollowingBackslash = false; |
|---|
| 230 | else if (lastChar=='\\') needFollowingBackslash = false; |
|---|
| 231 | else needFollowingBackslash = true; |
|---|
| 232 | needDirectoryName = true; |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | for(osgDB::DirectoryContents::iterator itr=dc.begin(); |
|---|
| 236 | itr!=dc.end(); |
|---|
| 237 | ++itr) |
|---|
| 238 | { |
|---|
| 239 | if ((caseSensitivity==CASE_INSENSITIVE && osgDB::equalCaseInsensitive(fileName,*itr)) || |
|---|
| 240 | (fileName==*itr)) |
|---|
| 241 | { |
|---|
| 242 | if (!needDirectoryName) return *itr; |
|---|
| 243 | else if (needFollowingBackslash) return dirName+'/'+*itr; |
|---|
| 244 | else return dirName+*itr; |
|---|
| 245 | } |
|---|
| 246 | } |
|---|
| 247 | return ""; |
|---|
| 248 | } |
|---|
| 249 | |
|---|
| 250 | #if defined(WIN32) && !defined(__CYGWIN__) |
|---|
| 251 | #include <io.h> |
|---|
| 252 | #include <direct.h> |
|---|
| 253 | |
|---|
| 254 | osgDB::DirectoryContents osgDB::getDirectoryContents(const std::string& dirName) |
|---|
| 255 | { |
|---|
| 256 | osgDB::DirectoryContents contents; |
|---|
| 257 | |
|---|
| 258 | WIN32_FIND_DATA data; |
|---|
| 259 | HANDLE handle = FindFirstFile((dirName + "\\*").c_str(), &data); |
|---|
| 260 | if (handle != INVALID_HANDLE_VALUE) |
|---|
| 261 | { |
|---|
| 262 | do |
|---|
| 263 | { |
|---|
| 264 | contents.push_back(data.cFileName); |
|---|
| 265 | } |
|---|
| 266 | while (FindNextFile(handle, &data) != 0); |
|---|
| 267 | |
|---|
| 268 | FindClose(handle); |
|---|
| 269 | } |
|---|
| 270 | return contents; |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | #else |
|---|
| 274 | |
|---|
| 275 | #include <dirent.h> |
|---|
| 276 | osgDB::DirectoryContents osgDB::getDirectoryContents(const std::string& dirName) |
|---|
| 277 | { |
|---|
| 278 | osgDB::DirectoryContents contents; |
|---|
| 279 | |
|---|
| 280 | DIR *handle = opendir(dirName.c_str()); |
|---|
| 281 | if (handle) |
|---|
| 282 | { |
|---|
| 283 | dirent *rc; |
|---|
| 284 | while((rc = readdir(handle))!=NULL) |
|---|
| 285 | { |
|---|
| 286 | contents.push_back(rc->d_name); |
|---|
| 287 | } |
|---|
| 288 | closedir(handle); |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | return contents; |
|---|
| 292 | } |
|---|
| 293 | |
|---|
| 294 | #endif // unix getDirectoryContexts |
|---|
| 295 | |
|---|
| 296 | #endif // ! target mac carbon |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | |
|---|
| 303 | |
|---|
| 304 | #ifdef __sgi |
|---|
| 305 | |
|---|
| 306 | void osgDB::appendPlatformSpecificLibraryFilePaths(FilePathList& filepath) |
|---|
| 307 | { |
|---|
| 308 | convertStringPathIntoFilePathList("/usr/lib32/:/usr/local/lib32/",filepath); |
|---|
| 309 | |
|---|
| 310 | |
|---|
| 311 | #if (_MIPS_SIM == _MIPS_SIM_ABI32) |
|---|
| 312 | |
|---|
| 313 | char* ptr; |
|---|
| 314 | if( (ptr = getenv( "LD_LIBRARY_PATH" ))) |
|---|
| 315 | { |
|---|
| 316 | convertStringPathIntoFilePathList(ptr,filepath); |
|---|
| 317 | } |
|---|
| 318 | |
|---|
| 319 | #elif (_MIPS_SIM == _MIPS_SIM_NABI32) |
|---|
| 320 | |
|---|
| 321 | if( !(ptr = getenv( "LD_LIBRARYN32_PATH" ))) |
|---|
| 322 | ptr = getenv( "LD_LIBRARY_PATH" ); |
|---|
| 323 | |
|---|
| 324 | if( ptr ) |
|---|
| 325 | { |
|---|
| 326 | convertStringPathIntoFilePathList(ptr,filepath); |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | #elif (_MIPS_SIM == _MIPS_SIM_ABI64) |
|---|
| 330 | |
|---|
| 331 | if( !(ptr = getenv( "LD_LIBRARY64_PATH" ))) |
|---|
| 332 | ptr = getenv( "LD_LIBRARY_PATH" ); |
|---|
| 333 | |
|---|
| 334 | if( ptr ) |
|---|
| 335 | { |
|---|
| 336 | convertStringPathIntoFilePathList(ptr,filepath); |
|---|
| 337 | } |
|---|
| 338 | #endif |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | #elif defined(__CYGWIN__) |
|---|
| 343 | |
|---|
| 344 | void osgDB::appendPlatformSpecificLibraryFilePaths(FilePathList& filepath) |
|---|
| 345 | { |
|---|
| 346 | char* ptr; |
|---|
| 347 | if ((ptr = getenv( "PATH" ))) |
|---|
| 348 | { |
|---|
| 349 | convertStringPathIntoFilePathList(ptr,filepath); |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | convertStringPathIntoFilePathList("/usr/bin/:/usr/local/bin/",filepath); |
|---|
| 353 | |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | #elif defined(WIN32) |
|---|
| 357 | |
|---|
| 358 | void osgDB::appendPlatformSpecificLibraryFilePaths(FilePathList& filepath) |
|---|
| 359 | { |
|---|
| 360 | char* ptr; |
|---|
| 361 | if ((ptr = getenv( "PATH" ))) |
|---|
| 362 | { |
|---|
| 363 | convertStringPathIntoFilePathList(ptr,filepath); |
|---|
| 364 | } |
|---|
| 365 | |
|---|
| 366 | convertStringPathIntoFilePathList("C:/Windows/System/",filepath); |
|---|
| 367 | } |
|---|
| 368 | |
|---|
| 369 | #elif defined(__APPLE__) |
|---|
| 370 | |
|---|
| 371 | |
|---|
| 372 | |
|---|
| 373 | |
|---|
| 374 | |
|---|
| 375 | |
|---|
| 376 | |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | |
|---|
| 380 | |
|---|
| 381 | |
|---|
| 382 | |
|---|
| 383 | |
|---|
| 384 | |
|---|
| 385 | #ifdef COMPILE_COCOA_VERSION_WITH_OBJECT-C++ |
|---|
| 386 | #include <Foundation/Foundation.h> |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | |
|---|
| 391 | |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | |
|---|
| 400 | |
|---|
| 401 | |
|---|
| 402 | |
|---|
| 403 | |
|---|
| 404 | |
|---|
| 405 | |
|---|
| 406 | |
|---|
| 407 | |
|---|
| 408 | |
|---|
| 409 | |
|---|
| 410 | |
|---|
| 411 | |
|---|
| 412 | |
|---|
| 413 | |
|---|
| 414 | void osgDB::appendPlatformSpecificLibraryFilePaths(FilePathList& filepath) |
|---|
| 415 | { |
|---|
| 416 | char* ptr; |
|---|
| 417 | if ((ptr = getenv( "DYLD_LIBRARY_PATH" )) ) |
|---|
| 418 | { |
|---|
| 419 | convertStringPathIntoFilePathList(ptr, filepath); |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | |
|---|
| 423 | |
|---|
| 424 | |
|---|
| 425 | |
|---|
| 426 | |
|---|
| 427 | |
|---|
| 428 | NSAutoreleasePool* mypool = [[NSAutoreleasePool alloc] init]; |
|---|
| 429 | |
|---|
| 430 | NSString* myBundlePlugInPath; |
|---|
| 431 | NSString* userSupportDir; |
|---|
| 432 | |
|---|
| 433 | |
|---|
| 434 | |
|---|
| 435 | |
|---|
| 436 | myBundlePlugInPath = [[NSBundle mainBundle] builtInPlugInsPath]; |
|---|
| 437 | |
|---|
| 438 | |
|---|
| 439 | |
|---|
| 440 | |
|---|
| 441 | |
|---|
| 442 | userSupportDir = [@"~/Library/Application Support/OpenSceneGraph/PlugIns" stringByExpandingTildeInPath]; |
|---|
| 443 | |
|---|
| 444 | |
|---|
| 445 | |
|---|
| 446 | |
|---|
| 447 | |
|---|
| 448 | |
|---|
| 449 | filepath.push_back( [myBundlePlugInPath UTF8String] ); |
|---|
| 450 | filepath.push_back( [userSupportDir UTF8String] ); |
|---|
| 451 | |
|---|
| 452 | filepath.push_back( "/Library/Application Support/OpenSceneGraph/PlugIns" ); |
|---|
| 453 | filepath.push_back( "/Network/Library/Application Support/OpenSceneGraph/PlugIns" ); |
|---|
| 454 | |
|---|
| 455 | |
|---|
| 456 | [mypool release]; |
|---|
| 457 | } |
|---|
| 458 | |
|---|
| 459 | #else |
|---|
| 460 | |
|---|
| 461 | #include <CoreServices/CoreServices.h> |
|---|
| 462 | |
|---|
| 463 | |
|---|
| 464 | |
|---|
| 465 | |
|---|
| 466 | |
|---|
| 467 | |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | |
|---|
| 471 | |
|---|
| 472 | |
|---|
| 473 | |
|---|
| 474 | |
|---|
| 475 | |
|---|
| 476 | |
|---|
| 477 | |
|---|
| 478 | |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | |
|---|
| 484 | |
|---|
| 485 | |
|---|
| 486 | |
|---|
| 487 | |
|---|
| 488 | |
|---|
| 489 | void osgDB::appendPlatformSpecificLibraryFilePaths(FilePathList& filepath) |
|---|
| 490 | { |
|---|
| 491 | char* ptr; |
|---|
| 492 | if ((ptr = getenv( "DYLD_LIBRARY_PATH" )) ) |
|---|
| 493 | { |
|---|
| 494 | convertStringPathIntoFilePathList(ptr, filepath); |
|---|
| 495 | } |
|---|
| 496 | |
|---|
| 497 | const int MAX_OSX_PATH_SIZE = 1024; |
|---|
| 498 | const std::string OSG_PLUGIN_PATH("/OpenSceneGraph/PlugIns"); |
|---|
| 499 | char buffer[MAX_OSX_PATH_SIZE]; |
|---|
| 500 | char bundlePathBuffer[MAX_OSX_PATH_SIZE]; |
|---|
| 501 | CFURLRef url; |
|---|
| 502 | CFStringRef pathString; |
|---|
| 503 | CFBundleRef myBundle; |
|---|
| 504 | CFStringRef bundlePathString; |
|---|
| 505 | FSRef f; |
|---|
| 506 | OSErr errCode; |
|---|
| 507 | |
|---|
| 508 | |
|---|
| 509 | |
|---|
| 510 | |
|---|
| 511 | |
|---|
| 512 | |
|---|
| 513 | |
|---|
| 514 | |
|---|
| 515 | myBundle = CFBundleGetMainBundle(); |
|---|
| 516 | if(myBundle != NULL) |
|---|
| 517 | { |
|---|
| 518 | |
|---|
| 519 | url = CFBundleCopyBundleURL( myBundle ); |
|---|
| 520 | |
|---|
| 521 | |
|---|
| 522 | bundlePathString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle ); |
|---|
| 523 | |
|---|
| 524 | CFStringGetCString( bundlePathString, bundlePathBuffer, MAX_OSX_PATH_SIZE, kCFStringEncodingUTF8 ); |
|---|
| 525 | |
|---|
| 526 | CFRelease( url ); |
|---|
| 527 | |
|---|
| 528 | |
|---|
| 529 | |
|---|
| 530 | url = CFBundleCopyBuiltInPlugInsURL( myBundle ); |
|---|
| 531 | |
|---|
| 532 | |
|---|
| 533 | pathString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle ); |
|---|
| 534 | |
|---|
| 535 | CFStringGetCString( pathString, buffer, MAX_OSX_PATH_SIZE, kCFStringEncodingUTF8 ); |
|---|
| 536 | |
|---|
| 537 | |
|---|
| 538 | filepath.push_back( |
|---|
| 539 | std::string(bundlePathBuffer) |
|---|
| 540 | + std::string("/") |
|---|
| 541 | + std::string(buffer) |
|---|
| 542 | ); |
|---|
| 543 | |
|---|
| 544 | CFRelease( pathString ); |
|---|
| 545 | CFRelease( bundlePathString ); |
|---|
| 546 | CFRelease( url ); |
|---|
| 547 | |
|---|
| 548 | |
|---|
| 549 | |
|---|
| 550 | |
|---|
| 551 | |
|---|
| 552 | |
|---|
| 553 | |
|---|
| 554 | pathString = NULL; |
|---|
| 555 | bundlePathString = NULL; |
|---|
| 556 | url = NULL; |
|---|
| 557 | |
|---|
| 558 | } |
|---|
| 559 | else |
|---|
| 560 | { |
|---|
| 561 | notify( DEBUG_INFO ) << "Couldn't find the Application Bundle" << std::endl; |
|---|
| 562 | } |
|---|
| 563 | |
|---|
| 564 | |
|---|
| 565 | errCode = FSFindFolder( kUserDomain, kApplicationSupportFolderType, kDontCreateFolder, &f ); |
|---|
| 566 | if(noErr == errCode) |
|---|
| 567 | { |
|---|
| 568 | |
|---|
| 569 | url = CFURLCreateFromFSRef( 0, &f ); |
|---|
| 570 | |
|---|
| 571 | pathString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle ); |
|---|
| 572 | |
|---|
| 573 | CFStringGetCString( pathString, buffer, MAX_OSX_PATH_SIZE, kCFStringEncodingUTF8 ); |
|---|
| 574 | |
|---|
| 575 | |
|---|
| 576 | filepath.push_back( |
|---|
| 577 | std::string(buffer) |
|---|
| 578 | + OSG_PLUGIN_PATH |
|---|
| 579 | ); |
|---|
| 580 | |
|---|
| 581 | CFRelease( url ); |
|---|
| 582 | CFRelease( pathString ); |
|---|
| 583 | } |
|---|
| 584 | else |
|---|
| 585 | { |
|---|
| 586 | notify( DEBUG_INFO ) << "Couldn't find the User's Application Support Path" << std::endl; |
|---|
| 587 | } |
|---|
| 588 | |
|---|
| 589 | |
|---|
| 590 | errCode = FSFindFolder( kLocalDomain, kApplicationSupportFolderType, kDontCreateFolder, &f ); |
|---|
| 591 | if(noErr == errCode) |
|---|
| 592 | { |
|---|
| 593 | |
|---|
| 594 | url = CFURLCreateFromFSRef( 0, &f ); |
|---|
| 595 | |
|---|
| 596 | pathString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle ); |
|---|
| 597 | |
|---|
| 598 | CFStringGetCString( pathString, buffer, MAX_OSX_PATH_SIZE, kCFStringEncodingUTF8 ); |
|---|
| 599 | |
|---|
| 600 | |
|---|
| 601 | filepath.push_back( |
|---|
| 602 | std::string(buffer) |
|---|
| 603 | + OSG_PLUGIN_PATH |
|---|
| 604 | ); |
|---|
| 605 | |
|---|
| 606 | CFRelease( url ); |
|---|
| 607 | CFRelease( pathString ); |
|---|
| 608 | } |
|---|
| 609 | else |
|---|
| 610 | { |
|---|
| 611 | notify( DEBUG_INFO ) << "Couldn't find the Local System's Application Support Path" << std::endl; |
|---|
| 612 | } |
|---|
| 613 | |
|---|
| 614 | |
|---|
| 615 | |
|---|
| 616 | |
|---|
| 617 | errCode = FSFindFolder( kNetworkDomain, kApplicationSupportFolderType, kDontCreateFolder, &f ); |
|---|
| 618 | if(noErr == errCode) |
|---|
| 619 | { |
|---|
| 620 | |
|---|
| 621 | url = CFURLCreateFromFSRef( 0, &f ); |
|---|
| 622 | |
|---|
| 623 | pathString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle ); |
|---|
| 624 | |
|---|
| 625 | CFStringGetCString( pathString, buffer, MAX_OSX_PATH_SIZE, kCFStringEncodingUTF8 ); |
|---|
| 626 | |
|---|
| 627 | |
|---|
| 628 | filepath.push_back( |
|---|
| 629 | std::string(buffer) |
|---|
| 630 | + OSG_PLUGIN_PATH |
|---|
| 631 | ); |
|---|
| 632 | |
|---|
| 633 | CFRelease( url ); |
|---|
| 634 | CFRelease( pathString ); |
|---|
| 635 | } |
|---|
| 636 | else |
|---|
| 637 | { |
|---|
| 638 | notify( DEBUG_INFO ) << "Couldn't find the Network Application Support Path" << std::endl; |
|---|
| 639 | } |
|---|
| 640 | } |
|---|
| 641 | |
|---|
| 642 | #endif |
|---|
| 643 | |
|---|
| 644 | #else |
|---|
| 645 | |
|---|
| 646 | void osgDB::appendPlatformSpecificLibraryFilePaths(FilePathList& filepath) |
|---|
| 647 | { |
|---|
| 648 | |
|---|
| 649 | char* ptr; |
|---|
| 650 | if( (ptr = getenv( "LD_LIBRARY_PATH" )) ) |
|---|
| 651 | { |
|---|
| 652 | convertStringPathIntoFilePathList(ptr,filepath); |
|---|
| 653 | } |
|---|
| 654 | |
|---|
| 655 | convertStringPathIntoFilePathList("/usr/lib/:/usr/local/lib/",filepath); |
|---|
| 656 | |
|---|
| 657 | } |
|---|
| 658 | |
|---|
| 659 | #endif |
|---|
| 660 | |
|---|
| 661 | |
|---|
| 662 | |
|---|
| 663 | |
|---|
| 664 | |
|---|
| 665 | |
|---|
| 666 | |
|---|
| 667 | |
|---|
| 668 | |
|---|