Changeset 20867

Show
Ignore:
Timestamp:
09/26/07 13:39:06 (1 year ago)
Author:
patrick
Message:

Catch any Boost.Filesystem exceptions being thrown while constructing the
plug-in search path.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/sonix/snx/SoundFactory.cpp

    r20849 r20867  
    9595   } 
    9696 
    97    const fs::path snx_base_dir(base_dir_env, fs::native); 
     97   std::vector<fs::path> search_paths; 
     98 
     99   try 
     100   { 
     101      const fs::path snx_base_dir(base_dir_env, fs::native); 
    98102 
    99103#if defined(VPR_OS_IRIX) && defined(_ABIN32) 
    100    const fs::path snx_lib_dir = snx_base_dir / "lib32"; 
     104      const fs::path snx_lib_dir = snx_base_dir / "lib32"; 
    101105#elif defined(VPR_OS_IRIX) && defined(_ABI64) || \ 
    102106      defined(VPR_OS_Linux) && defined(__x86_64__) 
    103    const fs::path snx_lib_dir = snx_base_dir / "lib64"; 
    104 #else 
    105    const fs::path snx_lib_dir = snx_base_dir / "lib"; 
    106 #endif 
     107      const fs::path snx_lib_dir = snx_base_dir / "lib64"; 
     108#else 
     109      const fs::path snx_lib_dir = snx_base_dir / "lib"; 
     110#endif 
     111 
     112      const std::string sonix_subdir_base("sonix"); 
     113 
     114      // If versioning is enabled, then the name of the directory containing 
     115      // the Sonix plug-ins must contain version information. 
     116#if defined(SNX_USE_VERSIONING) 
     117      std::string sonix_ver_str; 
     118      const std::string sonix_version("SNX_VERSION"); 
     119 
     120      // If $SNX_VERSION is set, use the value of that environment variable 
     121      // as the version component of the plug-in subdirectory name. Otherwise, 
     122      // use the compile-time value provided by SNX_VERSION_DOT. 
     123      if ( ! vpr::System::getenv(sonix_version, sonix_ver_str) ) 
     124      { 
     125         sonix_ver_str = SNX_VERSION_DOT; 
     126      } 
     127 
     128      fs::path sonix_subdir( 
     129         snx_lib_dir / (sonix_subdir_base + "-" + sonix_ver_str) / "plugins" 
     130      ); 
     131 
     132      // If versioning is not enabled, then the directory containing the 
     133      // Sonix plug-ins will not incorporate version information. 
     134#else 
     135      fs::path sonix_subdir(snx_lib_dir / sonix_subdir_base / "plugins"); 
     136#endif 
     137 
     138#if defined(SNX_DEBUG) 
     139#if defined(_DEBUG) 
     140      sonix_subdir /= "dbgrt"; 
     141#else 
     142      sonix_subdir /= "dbg"; 
     143#endif 
     144#else 
     145      sonix_subdir /= "opt"; 
     146#endif 
     147 
     148      search_paths.push_back(sonix_subdir); 
     149 
     150      std::string home_dir; 
     151      if ( vpr::System::getenv("HOME", home_dir) ) 
     152      { 
     153         search_paths.push_back( 
     154            fs::path(home_dir, fs::native) / fs::path(".sonix", fs::native) / 
     155               "plugins" 
     156         ); 
     157      } 
     158   } 
     159   catch (fs::filesystem_error& ex) 
     160   { 
     161      vprDEBUG(snxDBG, vprDBG_WARNING_LVL) 
     162         << clrOutNORM(clrRED, "WARNING") 
     163         << ": File system exception caught while constructing search " 
     164         << "path: " << std::endl << ex.what() << std::endl 
     165         << vprDEBUG_FLUSH; 
     166   } 
    107167 
    108168#if defined(VPR_OS_Windows) 
     
    113173   const std::string driver_ext("so"); 
    114174#endif 
    115  
    116    const std::string sonix_subdir_base("sonix"); 
    117  
    118    // If versioning is enabled, then the name of the directory containing the 
    119    // Sonix plug-ins must contain version information. 
    120 #if defined(SNX_USE_VERSIONING) 
    121    std::string sonix_ver_str; 
    122    const std::string sonix_version("SNX_VERSION"); 
    123  
    124    // If $SNX_VERSION is set, use the value of that environment variable 
    125    // as the version component of the plug-in subdirectory name. Otherwise, 
    126    // use the compile-time value provided by SNX_VERSION_DOT. 
    127    if ( ! vpr::System::getenv(sonix_version, sonix_ver_str) ) 
    128    { 
    129       sonix_ver_str = SNX_VERSION_DOT; 
    130    } 
    131  
    132    fs::path sonix_subdir( 
    133       snx_lib_dir / (sonix_subdir_base + "-" + sonix_ver_str) / "plugins" 
    134    ); 
    135  
    136    // If versioning is not enabled, then the directory containing the 
    137    // Sonix plug-ins will not incorporate version information. 
    138 #else 
    139    fs::path sonix_subdir(snx_lib_dir / sonix_subdir_base / "plugins"); 
    140 #endif 
    141  
    142 #if defined(SNX_DEBUG) 
    143 #if defined(_DEBUG) 
    144    sonix_subdir /= "dbgrt"; 
    145 #else 
    146    sonix_subdir /= "dbg"; 
    147 #endif 
    148 #else 
    149    sonix_subdir /= "opt"; 
    150 #endif 
    151  
    152    std::vector<fs::path> search_paths; 
    153    search_paths.push_back(sonix_subdir); 
    154  
    155    std::string home_dir; 
    156    if ( vpr::System::getenv("HOME", home_dir) ) 
    157    { 
    158       search_paths.push_back( 
    159          fs::path(home_dir, fs::native) / ".sonix" / "plugins" 
    160       ); 
    161    } 
    162175 
    163176   typedef std::vector<fs::path>::iterator iter_type;