Ignore:
Timestamp:
06/16/11 19:41:33 (13 years ago)
Author:
tbretz
Message:
'UnLibToolize' the program name.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Configuration.cc

    r11020 r11039  
    467467//!
    468468//
    469 Configuration::Configuration(const string &prgname) : fName(prgname),
     469Configuration::Configuration(const string &prgname) : fName(UnLibToolize(prgname)),
    470470fNameMapper(bind1st(mem_fun(&Configuration::DefaultMapper), this)),
    471471fPrintUsage(boost::bind(&Configuration::PrintUsage, this))
     
    493493    po::options_description def_config;
    494494    def_config.add_options()
    495         ("default",  var<string>(prgname+string(".rc")), "Default configuration file.")
     495        ("default",  var<string>(fName+string(".rc")), "Default configuration file.")
    496496        ;
    497497
     
    10351035// --------------------------------------------------------------------------
    10361036//
     1037//! Removes /.libs/lt- from a path or just lt- from the filename.
     1038//!
     1039//! @param src
     1040//!    input path with filename
     1041//! @returns
     1042//!    path cleaned from libtool extensions
     1043//!
     1044string Configuration::UnLibToolize(const string &src) const
     1045{
     1046    const boost::filesystem::path path(src);
     1047
     1048    string pname = path.parent_path().string();
     1049    string fname = path.filename();
     1050
     1051    if (fname.substr(0, 3)=="lt-")
     1052        fname = fname.substr(3);
     1053
     1054    if (pname==".libs")
     1055        return fname;
     1056
     1057    const size_t pos = pname.length()-6;
     1058    if (pname.substr(pos)=="/.libs")
     1059        pname = pname.substr(0, pos);
     1060
     1061    return pname+'/'+fname;
     1062}
     1063
     1064// --------------------------------------------------------------------------
     1065//
    10371066//! Print version information about the program and package.
    10381067//!
     
    10921121    }
    10931122
    1094     std::string n = boost::filesystem::basename(fName);
    1095     if (n.substr(0, 3)=="lt-")
    1096         n = n.substr(3);
     1123    const std::string n = boost::filesystem::path(fName).filename();
    10971124
    10981125    const string name = PACKAGE_STRING;
Note: See TracChangeset for help on using the changeset viewer.