title: boost filename extension with multiple "."
body: <p>I have filenames like this : <code>09.04.201115_09_ch_4.txt</code></p>
  
  <p>I would like to extract the filestem only. I tried using boost filesystem path, but it has problems with the multiple dots in the filename. (I didn't come up with the naming).</p>
  
  <p>Is there a way around that? Can I get only the filename without the extension? My code looks like this:</p>
  
  <pre><code> std::string stringtmp = path.parent_path().string() +"/"+path.stem().string()+".png" ;
  </code></pre>
  
  <p>Ok here's the code (it's using the ROOT framework):</p>
  
  <pre><code>#include "TH1F.h"
  #include "TH2F.h"
  #include "TF1.h"
  #include "TSpectrum.h"
  #include "TCanvas.h"
  #include "TVirtualFitter.h"
  #include "TMath.h"
  #include "TGraph.h"
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include "TApplication.h"
  #include "TImage.h"
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include "TStyle.h"
  #include "TROOT.h"
  #include "TGraph2D.h"
  #include "boost/filesystem.hpp"
  
  
  Int_t npeaks = 10;
  Double_t fpeaks(Double_t *x, Double_t *par) {
  Double_t result = par[0] + par[1]*x[0];
  for (Int_t p=0;p&lt;npeaks;p++) {
    Double_t norm  = par[3*p+2];
    Double_t mean  = par[3*p+3];
    Double_t sigma = par[3*p+4];
    result += norm*TMath::Gaus(x[0],mean,sigma);
  }
  return result;
  }
  
  
  void graph(std::string name, bool big){
  Float_t x[5001],y[5001];
  std::ifstream in;
  TCanvas *c1 = new TCanvas("c1","c1",10,10,1000,500);
   if(!big){
    in.open(name.c_str());
  
  for(Int_t i = 0 ; i&lt; 5001 ;i++){
    in &gt;&gt; x[i] &gt;&gt; y[i];
  } 
  
  c1-&gt;cd(1);
  TGraph *gr = new TGraph(5001,x,y);
  gr-&gt;SetMinimum(-60.);
  //gr-&gt;GetYAxis()-&gt;SetMinimum(-70.);
  // gr-&gt;GetYAxis()-&gt;SetTitle("dB");
  gr-&gt;Draw("A*");
  TH1F *h = gr-&gt;GetHistogram();
  for(Int_t i = 0 ; i&lt; 5001 ;i++){
    if(y[i]&gt;= -60.)
    h-&gt;SetBinContent(i,y[i]);
  }
  //c1-&gt;cd(2);
  h-&gt;SetYTitle("Intensity in dB");
  h-&gt;SetXTitle("#lambda in nm");
  h-&gt;SetTitle("Sectrum");
  h-&gt;Draw();
  
  TSpectrum *s = new TSpectrum(1000);
  Int_t nfound = s-&gt;Search(h,1,"new");
  std::cout &lt;&lt;"Found " &lt;&lt; nfound &lt;&lt; " candiate peaks to fit\n";
  c1-&gt;Update();
  
  //estimate linear background
   Double_t par[3000];
  TF1 *fline = new TF1("fline","pol1",842,852);
  h-&gt;Fit("fline","qn");
  //c1-&gt;cd(2);
  par[0] = fline-&gt;GetParameter(0);
  par[1] = fline-&gt;GetParameter(1);
  //loop on all found peaks. Eliminate peaks at the background level
    Float_t *xpeaks = s-&gt;GetPositionX();
  for (Int_t p=0;p&lt;nfound;p++) {
    Float_t xp = xpeaks[p];
    Int_t bin = h-&gt;GetXaxis()-&gt;FindBin(xp);
    Float_t yp = h-&gt;GetBinContent(bin);
    if (yp-TMath::Sqrt(yp) &lt; fline-&gt;Eval(xp)) continue;
    par[3*npeaks+2] = yp;
    par[3*npeaks+3] = xp;
    par[3*npeaks+4] = 3;
    npeaks++;
    }
  c1-&gt;Update();
  
  TImage *img = TImage::Create();
  
  img-&gt;FromPad(c1);
  std::stringstream _name;
  _name &lt;&lt; name &lt;&lt; ".png";
  _name &gt;&gt; name;
  boost::filesystem::path path(name);
  std::string stringtmp = path.parent_path().string() +"/"+path.stem().string()+".png" ;
  std::cout &lt;&lt;"\n \n stem \n \n"&lt;&lt;stringtmp&lt;&lt; '\t' &lt;&lt; path.stem().string() &lt;&lt; std::endl;
  img-&gt;WriteImage(stringtmp.c_str());
  return;
  } 
  </code></pre>
  
  <p>The output looks like this:</p>
  
  <p>Warning in : Deleting canvas with same name: c1</p>
  
  <p>Found 39 candiate peaks to fit</p>
  
  <pre><code>stem 
  
  29/12.04.201115_09_ch_4.txt.png 12.04.201115_09_ch_4.txt
  </code></pre>