Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 17, 2011, 5:47:22 AM (13 years ago)
Author:
rgrieder
Message:

Stripped down trunk to form a new light sandbox.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/forks/sandbox_light/src/libraries/core/PathConfig.cc

    r6417 r7908  
    7676        : rootPath_(*(new bf::path()))
    7777        , executablePath_(*(new bf::path()))
    78         , modulePath_(*(new bf::path()))
    7978        , dataPath_(*(new bf::path()))
    80         , externalDataPath_(*(new bf::path()))
    8179        , configPath_(*(new bf::path()))
    8280        , logPath_(*(new bf::path()))
     
    138136            COUT(1) << "Running from the build tree." << std::endl;
    139137            PathConfig::bDevRun_ = true;
    140             modulePath_ = specialConfig::moduleDevDirectory;
    141138        }
    142139        else
     
    153150                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
    154151
    155             // Module path is fixed as well
    156             modulePath_ = rootPath_ / specialConfig::defaultModulePath;
    157 
    158152#else
    159153
    160154            // There is no root path, so don't set it at all
    161             // Module path is fixed as well
    162             modulePath_ = specialConfig::moduleInstallDirectory;
    163155
    164156#endif
     
    170162        delete &rootPath_;
    171163        delete &executablePath_;
    172         delete &modulePath_;
    173164        delete &dataPath_;
    174         delete &externalDataPath_;
    175165        delete &configPath_;
    176166        delete &logPath_;
     
    184174            configPath_       = specialConfig::configDevDirectory;
    185175            logPath_          = specialConfig::logDevDirectory;
    186 
    187             // Check for data path override by the command line
    188             if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
    189                 externalDataPath_ = CommandLineParser::getValue("externalDataPath").getString();
    190             else
    191                 externalDataPath_ = specialConfig::externalDataDevDirectory;
    192176        }
    193177        else
     
    251235    }
    252236
    253     std::vector<std::string> PathConfig::getModulePaths()
    254     {
    255         std::vector<std::string> modulePaths;
    256 
    257         // We search for helper files with the following extension
    258         const std::string& moduleextension = specialConfig::moduleExtension;
    259         size_t moduleextensionlength = moduleextension.size();
    260 
    261         // Add that path to the PATH variable in case a module depends on another one
    262         std::string pathVariable(getenv("PATH"));
    263         putenv(const_cast<char*>(("PATH=" + pathVariable + ';' + modulePath_.string()).c_str()));
    264 
    265         // Make sure the path exists, otherwise don't load modules
    266         if (!boost::filesystem::exists(modulePath_))
    267             return modulePaths;
    268 
    269         boost::filesystem::directory_iterator file(modulePath_);
    270         boost::filesystem::directory_iterator end;
    271 
    272         // Iterate through all files
    273         while (file != end)
    274         {
    275             const std::string& filename = file->BOOST_LEAF_FUNCTION();
    276 
    277             // Check if the file ends with the exension in question
    278             if (filename.size() > moduleextensionlength)
    279             {
    280                 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
    281                 {
    282                     // We've found a helper file
    283                     const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);
    284                     modulePaths.push_back((modulePath_ / library).file_string());
    285                 }
    286             }
    287             ++file;
    288         }
    289 
    290         return modulePaths;
    291     }
    292 
    293237    /*static*/ std::string PathConfig::getRootPathString()
    294238    {
     
    306250    }
    307251
    308     /*static*/ std::string PathConfig::getExternalDataPathString()
    309     {
    310         return getInstance().externalDataPath_.string() + '/';
    311     }
    312 
    313252    /*static*/ std::string PathConfig::getConfigPathString()
    314253    {
     
    320259        return getInstance().logPath_.string() + '/';
    321260    }
    322 
    323     /*static*/ std::string PathConfig::getModulePathString()
    324     {
    325         return getInstance().modulePath_.string() + '/';
    326     }
    327261}
Note: See TracChangeset for help on using the changeset viewer.