Changeset 9991
- Timestamp:
- 04/08/09 15:11:27 (4 years ago)
- Location:
- OpenSceneGraph/trunk/src/osgDB
- Files:
-
- 2 modified
-
CMakeLists.txt (modified) (1 diff)
-
FileUtils.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgDB/CMakeLists.txt
r9949 r9991 1 1 2 IF(DYNAMIC_OPENSCENEGRAPH) 2 IF (DYNAMIC_OPENSCENEGRAPH) 3 4 OPTION(OSG_PLUGIN_SEARCH_INSTALL_DIR_FOR_PLUGINS "Set to ON to have OpenSceneGraph search the configured install directory for plugins." ON) 5 3 6 ADD_DEFINITIONS(-DOSGDB_LIBRARY) 4 7 5 # Add a default plugin search path component 6 ADD_DEFINITIONS(-DOSG_DEFAULT_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}/${OSG_PLUGINS}) 7 ELSE() 8 IF(OSG_PLUGIN_SEARCH_INSTALL_DIR_FOR_PLUGINS) 9 # Add a default plugin search path component 10 ADD_DEFINITIONS(-DOSG_DEFAULT_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}/${OSG_PLUGINS}) 11 ENDIF() 12 13 ELSE () 8 14 ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC) 9 15 ENDIF() -
OpenSceneGraph/trunk/src/osgDB/FileUtils.cpp
r9475 r9991 18 18 #if defined(WIN32) && !defined(__CYGWIN__) 19 19 #include <io.h> 20 #define WINBASE_DECLARE_GET_MODULE_HANDLE_EX 20 21 #include <windows.h> 21 22 #include <winbase.h> … … 87 88 #define OSGDB_FILENAME_TEXT(x) L ## x 88 89 #define OSGDB_WINDOWS_FUNCT(x) x ## W 90 #define OSGDB_WINDOWS_FUNCT_STRING(x) L ## #x L"W" 89 91 typedef wchar_t filenamechar; 90 92 typedef std::wstring filenamestring; … … 94 96 #define OSGDB_FILENAME_TEXT(x) x 95 97 #define OSGDB_WINDOWS_FUNCT(x) x ## A 98 #define OSGDB_WINDOWS_FUNCT_STRING(x) #x "A" 96 99 typedef char filenamechar; 97 100 typedef std::string filenamestring; … … 649 652 } 650 653 651 // 2. The system directory. Use the GetSystemDirectory function to 654 // 2. The directory that the dll that contains this function is in. 655 // For static builds, this will be the executable directory. 656 657 // Requires use of the GetModuleHandleEx() function which is available only on Windows XP or higher. 658 // In order to allow execution on older versions, we load the function dynamically from the library and 659 // use it only if it's available. 660 bool addedDllDirectory = false; 661 OSGDB_WINDOWS_FUNCT(PGET_MODULE_HANDLE_EX) pGetModuleHandleEx = reinterpret_cast<OSGDB_WINDOWS_FUNCT(PGET_MODULE_HANDLE_EX)> 662 (GetProcAddress( GetModuleHandleA("kernel32.dll"), OSGDB_WINDOWS_FUNCT_STRING(GetModuleHandleEx))); 663 if( pGetModuleHandleEx ) 664 { 665 HMODULE thisModule = 0; 666 static char static_variable = 0; // Variable that is located in DLL address space. 667 668 if( pGetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, &static_variable, &thisModule) ) 669 { 670 retval = OSGDB_WINDOWS_FUNCT(GetModuleFileName)(thisModule, path, size); 671 if (retval != 0 && retval < size) 672 { 673 filenamestring pathstr(path); 674 filenamestring dllDir(pathstr, 0, 675 pathstr.find_last_of(OSGDB_FILENAME_TEXT("\\/"))); 676 convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(dllDir), filepath); 677 addedDllDirectory = true; 678 } 679 else 680 { 681 osg::notify(osg::WARN) << "Could not get dll directory " 682 "using Win32 API. It will not be searched." << std::endl; 683 } 684 } 685 else 686 { 687 osg::notify(osg::WARN) << "Could not get dll module handle " 688 "using Win32 API. Dll directory will not be searched." << std::endl; 689 } 690 } 691 692 // 3. The system directory. Use the GetSystemDirectory function to 652 693 // get the path of this directory. 653 694 filenamechar systemDir[(UINT)size]; … … 667 708 } 668 709 669 // 3. The 16-bit system directory. There is no function that obtains710 // 4. The 16-bit system directory. There is no function that obtains 670 711 // the path of this directory, but it is searched. 671 // 4. The Windows directory. Use the GetWindowsDirectory function to712 // 5. The Windows directory. Use the GetWindowsDirectory function to 672 713 // get the path of this directory. 673 714 filenamechar windowsDir[(UINT)size]; … … 689 730 690 731 691 // 5. The current directory.732 // 6. The current directory. 692 733 convertStringPathIntoFilePathList(".", filepath); 693 734 694 // 6. The directories that are listed in the PATH environment735 // 7. The directories that are listed in the PATH environment 695 736 // variable. Note that this does not include the per-application 696 737 // path specified by the App Paths registry key.
