Show
Ignore:
Timestamp:
03/21/12 18:36:20 (2 years ago)
Author:
robert
Message:

Ran script to remove trailing spaces and tabs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgDB/FileUtils.cpp

    r12969 r13041  
    1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield  
     1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 
    22 * 
    3  * This library is open source and may be redistributed and/or modified under   
    4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or  
     3 * This library is open source and may be redistributed and/or modified under 
     4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
    55 * (at your option) any later version.  The full license is in LICENSE file 
    66 * included with this distribution, and on the openscenegraph.org website. 
    7  *  
     7 * 
    88 * This library is distributed in the hope that it will be useful, 
    99 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
     10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1111 * OpenSceneGraph Public License for more details. 
    1212*/ 
     
    3333    #include <sys/stat.h> 
    3434    #include <direct.h> // for _mkdir 
    35      
     35 
    3636    #define mkdir(x,y) _mkdir((x)) 
    3737    #define stat64 _stati64 
     
    5252    //IOS includes 
    5353    #include "TargetConditionals.h" 
    54      
    55     #if (TARGET_OS_IPHONE)  
     54 
     55    #if (TARGET_OS_IPHONE) 
    5656        #include <Availability.h> 
    5757        // workaround a bug which appears when compiling for SDK < 4.0 and for the simulator 
    5858        #ifdef __IPHONE_4_0 && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0) 
    5959            #define stat64 stat 
    60         #else  
     60        #else 
    6161            #if !TARGET_IPHONE_SIMULATOR 
    6262                #define stat64 stat 
     
    6969    // By default, MAC_OS_X_VERSION_MAX_ALLOWED is set to the latest 
    7070    // system the headers know about. So I will use this as the control 
    71     // variable. (MIN_ALLOWED is set low by default so it is  
    72     // unhelpful in this case.)  
     71    // variable. (MIN_ALLOWED is set low by default so it is 
     72    // unhelpful in this case.) 
    7373    // Unfortunately, we can't use the label MAC_OS_X_VERSION_10_4 
    7474    // for older OS's like Jaguar, Panther since they are not defined, 
     
    145145        return false; 
    146146    } 
    147      
     147 
    148148    struct stat64 stbuf; 
    149149#ifdef OSG_USE_UTF8_FILENAME 
     
    169169        if( dir.empty() ) 
    170170            break; 
    171   
     171 
    172172#ifdef OSG_USE_UTF8_FILENAME 
    173173        if( _wstat64( OSGDB_STRING_TO_FILENAME(dir).c_str(), &stbuf ) < 0 ) 
     
    182182                    paths.push( dir ); 
    183183                    break; 
    184   
     184 
    185185                default: 
    186186                    OSG_DEBUG << "osgDB::makeDirectory(): "  << strerror(errno) << std::endl; 
     
    194194    { 
    195195        std::string dir = paths.top(); 
    196   
     196 
    197197        #if defined(WIN32) 
    198198            //catch drive name 
     
    211211            OSG_DEBUG << "osgDB::makeDirectory(): "  << strerror(errno) << std::endl; 
    212212            return false; 
    213         }  
     213        } 
    214214        paths.pop(); 
    215215    } 
     
    246246        return false; 
    247247    } 
    248      
     248 
    249249#ifdef OSG_USE_UTF8_FILENAME 
    250250    return _wchdir( OSGDB_STRING_TO_FILENAME(newCurrentWorkingDirectory).c_str()) == 0; 
     
    280280            filepath.push_back(lastPath); 
    281281    } 
    282   
     282 
    283283} 
    284284 
     
    314314std::string osgDB::findFileInPath(const std::string& filename, const FilePathList& filepath,CaseSensitivity caseSensitivity) 
    315315{ 
    316     if (filename.empty())  
     316    if (filename.empty()) 
    317317        return filename; 
    318318 
    319     if (!isFileNameNativeStyle(filename))  
     319    if (!isFileNameNativeStyle(filename)) 
    320320        return findFileInPath(convertFileNameToNativeStyle(filename), filepath, caseSensitivity); 
    321321 
     
    327327        OSG_DEBUG << "itr='" <<*itr<< "'\n"; 
    328328        std::string path = itr->empty() ? filename : concatPaths(*itr, filename); 
    329          
     329 
    330330        path = getRealPath(path); 
    331331 
    332332        OSG_DEBUG << "FindFileInPath() : trying " << path << " ...\n"; 
    333         if(fileExists(path))  
     333        if(fileExists(path)) 
    334334        { 
    335335            OSG_DEBUG << "FindFileInPath() : USING " << path << "\n"; 
    336336            return path; 
    337337        } 
    338 #ifndef WIN32  
     338#ifndef WIN32 
    339339// windows already case insensitive so no need to retry.. 
    340         else if (caseSensitivity==CASE_INSENSITIVE)  
     340        else if (caseSensitivity==CASE_INSENSITIVE) 
    341341        { 
    342342            std::string foundfile = findFileInDirectory(filename,*itr,CASE_INSENSITIVE); 
     
    344344        } 
    345345#endif 
    346              
     346 
    347347    } 
    348348 
     
    381381        bool win32 = false; 
    382382    #endif 
    383      
     383 
    384384    // If the fileName contains extra path information, make that part of the 
    385385    // directory name instead 
     
    459459                realDirName = findFileInDirectory(lastElement, parentPath, 
    460460                                                  CASE_INSENSITIVE); 
    461        
     461 
    462462                dc = osgDB::getDirectoryContents(realDirName); 
    463463                char lastChar = realDirName[realDirName.size()-1]; 
     
    724724        convertStringPathIntoFilePathList("/usr/bin/:/usr/local/bin/",filepath); 
    725725    } 
    726      
     726 
    727727#elif defined(WIN32) 
    728728 
     
    731731        // See http://msdn2.microsoft.com/en-us/library/ms682586.aspx 
    732732 
    733         // Safe DLL search mode changes the DLL search order to search for  
     733        // Safe DLL search mode changes the DLL search order to search for 
    734734        // DLLs in the current directory after the system directories, instead 
    735         // of right after the application's directory. According to the article  
    736         // linked above, on Windows XP and Windows 2000, Safe DLL search mode  
    737         // is disabled by default. However, it is a good idea to enable it. We  
     735        // of right after the application's directory. According to the article 
     736        // linked above, on Windows XP and Windows 2000, Safe DLL search mode 
     737        // is disabled by default. However, it is a good idea to enable it. We 
    738738        // will search as if it was enabled. 
    739739 
     
    748748        { 
    749749            filenamestring pathstr(path); 
    750             filenamestring executableDir(pathstr, 0,  
     750            filenamestring executableDir(pathstr, 0, 
    751751                                      pathstr.find_last_of(OSGDB_FILENAME_TEXT("\\/"))); 
    752752            convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(executableDir), filepath); 
     
    797797        #endif 
    798798 
    799         //   3. The system directory. Use the GetSystemDirectory function to  
     799        //   3. The system directory. Use the GetSystemDirectory function to 
    800800        //      get the path of this directory. 
    801801        filenamechar systemDir[(UINT)size]; 
     
    804804        if (retval != 0 && retval < size) 
    805805        { 
    806             convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(systemDir),  
     806            convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(systemDir), 
    807807                                              filepath); 
    808808        } 
     
    811811            OSG_WARN << "Could not get system directory using " 
    812812                "Win32 API, using default directory." << std::endl; 
    813             convertStringPathIntoFilePathList("C:\\Windows\\System32",  
     813            convertStringPathIntoFilePathList("C:\\Windows\\System32", 
    814814                                              filepath); 
    815815        } 
    816816 
    817         //   4. The 16-bit system directory. There is no function that obtains  
     817        //   4. The 16-bit system directory. There is no function that obtains 
    818818        //      the path of this directory, but it is searched. 
    819         //   5. The Windows directory. Use the GetWindowsDirectory function to  
     819        //   5. The Windows directory. Use the GetWindowsDirectory function to 
    820820        //      get the path of this directory. 
    821821        filenamechar windowsDir[(UINT)size]; 
     
    823823        if (retval != 0 && retval < size) 
    824824        { 
    825             convertStringPathIntoFilePathList(std::string(OSGDB_FILENAME_TO_STRING(windowsDir)) +  
     825            convertStringPathIntoFilePathList(std::string(OSGDB_FILENAME_TO_STRING(windowsDir)) + 
    826826                                              "\\System", filepath); 
    827             convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(windowsDir),  
     827            convertStringPathIntoFilePathList(OSGDB_FILENAME_TO_STRING(windowsDir), 
    828828                                              filepath); 
    829829        } 
     
    840840        convertStringPathIntoFilePathList(".", filepath); 
    841841 
    842         //   7. The directories that are listed in the PATH environment  
    843         //      variable. Note that this does not include the per-application  
     842        //   7. The directories that are listed in the PATH environment 
     843        //      variable. Note that this does not include the per-application 
    844844        //      path specified by the App Paths registry key. 
    845845        filenamechar* ptr; 
     
    859859        appendInstallationLibraryFilePaths(filepath); 
    860860    } 
    861      
     861 
    862862#elif defined(__APPLE__) 
    863863#if (TARGET_OS_IPHONE) 
     
    876876    #endif 
    877877    #include <iostream> 
    878      
     878 
    879879    // These functions are local to FileUtils.cpp and not exposed to the API 
    880880    // returns the path string except for numToShorten directories stripped off the end 
     
    913913        } 
    914914        return path; 
    915          
     915 
    916916    } 
    917917 
     
    931931        } 
    932932        return path; 
    933          
     933 
    934934    } 
    935935 
     
    948948    // The Cocoa version is about 10 lines of code. 
    949949    // The Carbon version is noticably longer. 
    950     // Unfortunately, the Cocoa version requires -lobjc to be  
    951     // linked in when creating an executable.  
     950    // Unfortunately, the Cocoa version requires -lobjc to be 
     951    // linked in when creating an executable. 
    952952    // Rumor is that this will be done autmatically in gcc 3.5/Tiger, 
    953953    // but for now, this will cause a lot of headaches for people 
    954     // who aren't familiar with this concept, so the Carbon version  
     954    // who aren't familiar with this concept, so the Carbon version 
    955955    // is preferable. 
    956956    // But for the curious, both implementations are here. 
    957     // Note that if the Cocoa version is used, the file should be  
     957    // Note that if the Cocoa version is used, the file should be 
    958958    // renamed to use the .mm extension to denote Objective-C++. 
    959959    // And of course, you will need to link against Cocoa 
    960     // Update: There is a bug in the Cocoa version. Advanced users can remap  
     960    // Update: There is a bug in the Cocoa version. Advanced users can remap 
    961961    // their systems so these paths go somewhere else. The Carbon calls 
    962962    // will catch this, but the hardcoded Cocoa code below will not. 
     
    969969    // /Library/Application Support/OpenSceneGraph/PlugIns 
    970970    // /Network/Library/Application Support/OpenSceneGraph/PlugIns 
    971     //  
    972     // As a side effect of this function, if the application is not a  
     971    // 
     972    // As a side effect of this function, if the application is not a 
    973973    // bundle, the first place searched becomes 
    974974    // YourProgram/PlugIns 
     
    977977    // ~/Library/Application Support/YourProgram/PlugIns 
    978978    // /Library/Application Support/YourProgram/PlugIns 
    979     // /Network/Library/Application Support/TheProgram/PlugIns  
    980     // But I'm not going to worry about it for now because the  
    981     // bundle's PlugIns directory is supposed to be the preferred  
     979    // /Network/Library/Application Support/TheProgram/PlugIns 
     980    // But I'm not going to worry about it for now because the 
     981    // bundle's PlugIns directory is supposed to be the preferred 
    982982    // place for this anyway. 
    983983    // 
     
    985985    // the directory the program resides in, 
    986986    // but I'm worried about multiplatform distribution. 
    987     // Because .so is used by other platforms like Linux, we  
     987    // Because .so is used by other platforms like Linux, we 
    988988    // could end up loading the wrong binary. 
    989989    // I'm not sure how robust the current code is for this case. 
    990     // Assuming the program doesn't crash, will OSG move on to the  
     990    // Assuming the program doesn't crash, will OSG move on to the 
    991991    // next search directory, or just give up? 
    992992    void osgDB::appendPlatformSpecificLibraryFilePaths(FilePathList& filepath) 
     
    10021002        // Since this is currently the only Objective-C code in the 
    10031003        // library, we need an autoreleasepool for obj-c memory management. 
    1004         // If more Obj-C is added, we might move this pool to another  
     1004        // If more Obj-C is added, we might move this pool to another 
    10051005        // location so it can be shared. Pools seem to be stackable, 
    10061006        // so I don't think there will be a problem if multiple pools 
     
    10181018        // Now setup the other search paths 
    10191019        // Cocoa has a nice method for tilde expansion. 
    1020         // There's probably a better way of getting this directory, but I  
     1020        // There's probably a better way of getting this directory, but I 
    10211021        // can't find the call. 
    10221022        userSupportDir = [@"~/Library/Application Support/OpenSceneGraph/PlugIns" stringByExpandingTildeInPath]; 
     
    10491049    // ~/Library/Application Support/YourProgram/PlugIns 
    10501050    // /Library/Application Support/YourProgram/PlugIns 
    1051     // /Network/Library/Application Support/TheProgram/PlugIns  
    1052     // But I'm not going to worry about it for now because the  
    1053     // bundle's PlugIns directory is supposed to be the preferred  
     1051    // /Network/Library/Application Support/TheProgram/PlugIns 
     1052    // But I'm not going to worry about it for now because the 
     1053    // bundle's PlugIns directory is supposed to be the preferred 
    10541054    // place for this anyway. 
    10551055    // 
     
    10571057    // the directory the program resides in, 
    10581058    // but I'm worried about multiplatform distribution. 
    1059     // Because .so is used by other platforms like Linux, we  
     1059    // Because .so is used by other platforms like Linux, we 
    10601060    // could end up loading the wrong binary. 
    10611061    // I'm not sure how robust the current code is for this case. 
    1062     // Assuming the program doesn't crash, will OSG move on to the  
     1062    // Assuming the program doesn't crash, will OSG move on to the 
    10631063    // next search directory, or just give up? 
    10641064    void osgDB::appendPlatformSpecificLibraryFilePaths(FilePathList& filepath) 
     
    10831083        //  we are not keeping a reference 
    10841084        myBundle = CFBundleGetMainBundle(); 
    1085          
     1085 
    10861086        if(myBundle != NULL) 
    10871087        { 
    1088             // CFBundleGetMainBundle will return a bundle ref even if  
     1088            // CFBundleGetMainBundle will return a bundle ref even if 
    10891089            //  the application isn't part of a bundle, so we need to check 
    10901090            //  if the path to the bundle ends in ".app" to see if it is a 
     
    11261126            // Get the URL 
    11271127            url = CFURLCreateFromFSRef( 0, &f ); 
    1128              
     1128 
    11291129            if(url) 
    11301130            { 
     
    11501150            // Get the URL 
    11511151            url = CFURLCreateFromFSRef( 0, &f ); 
    1152              
     1152 
    11531153            if(url) 
    11541154            { 
     
    11791179    } 
    11801180    #endif 
    1181      
    1182 #else    
     1181 
     1182#else 
    11831183 
    11841184    void osgDB::appendPlatformSpecificLibraryFilePaths(FilePathList& filepath) 
     
    12111211        // Get the main application bundle 
    12121212        CFBundleRef mainBundle = CFBundleGetMainBundle(); 
    1213          
     1213 
    12141214        if (mainBundle != NULL) { 
    12151215            // Get the parent directory and the resources directory 
    12161216            std::string bundlePath = GetApplicationBundlePath(mainBundle); 
    12171217            std::string resourcesPath = GetApplicationResourcesPath(mainBundle); 
    1218              
     1218 
    12191219            // check if application is really part of a .app bundle 
    12201220            if(bundlePath.substr(bundlePath.length() - 4, 4) == std::string(".app")) 
     
    12221222                if(resourcesPath != std::string("")) 
    12231223                    filepath.push_back( resourcesPath ); 
    1224                  
     1224 
    12251225                std::string parentPath = GetShortenedPath(bundlePath, 1); 
    12261226                if(parentPath != std::string(""))