source: trunk/IPs/systemC/processor/Morpheo/Common/src/Basename.cpp @ 144

Last change on this file since 144 was 144, checked in by rosiere, 14 years ago

1) compatible gcc 4.4.3
2) Translation file in MORPHEO_PREFIX directory

  • Property svn:keywords set to Id
File size: 535 bytes
Line 
1/*
2 * $Id: Basename.cpp 144 2010-09-28 11:19:10Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "../include/Basename.h"
9#include <libgen.h>
10
11namespace morpheo {
12
13  std::string basename (std::string str, bool keep_extension)
14  {
15    std::string res = ::basename(const_cast<char *>(str.c_str()));
16   
17    if (not keep_extension)
18      {
19        std::string::size_type index = res.rfind('.');
20       
21        if(index != std::string::npos)
22          {
23            res = res.substr(0,index);
24          }
25      }
26   
27    return res;
28  }
29 
30}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.