Example for how to split a full path into its components directory, base of filename and extension of the filename.
- Author
- woetzel
- Todo:
- Windows may need some more work regarding the drive, in particular for network drives \machine
#include <iostream>
#include "Base/Common/FileHandling.hh"
using namespace std;
using namespace BIAS;
int main(int argc,char** argv){
cout<<"current work directory "<<FileHandling::GetCwd()<<endl;
string full("/this/is/a/directory/ThisIsABase.ext");
string dir, base, ext;
if (argc>1) full=argv[1];
cout<<"Splitting "<<full<<" into: "<<endl;
FileHandling::SplitName(full, dir, base, ext);
cout<<"\tdir '"<<dir <<"'"<<endl
<<"\tbase '"<<base<<"'"<<endl
<<"\text '"<<ext <<"'"<<endl;
return 0;
}