Hello, I'm getting the following error with this code, also i would like to know how to add the path and filespec together with a and be able to split the 2 so it would be 3 args not 4.
ERROR:
error C2664: 'std::vector<_Ty>::vector(const std::allocator<_Ty> &)' : cannot convert parameter 1 from 'char *' to 'const std::allocator<_Ty> &'
This is my current code:
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
using namespace boost::filesystem;
#include <boost/regex.hpp>
void show_files( const path & directory, bool recurse_into_subdirs = false )
{
if( exists( directory ) )
{
directory_iterator end ;
for( directory_iterator iter(directory) ; iter != end ; ++iter )
if ( is_directory( *iter ) )
{
cout << "\nd " << iter->path() ;
if( recurse_into_subdirs ) show_files(*iter) ;
}
else
cout << "\n- " << iter->path() ;
}
}
int main(int argc, char *argv[])
{
if (argc != 4)
{
cout << "Usage: program.exe [switches] [path] [filespec]" << endl;
}
else
{
vector<string> s_switches(argv[1]);
string s_path(argv[2]);
string s_filespec(argv[3]);
cout << s_switches[1] << endl;
bool aSwitch = false;
bool rSwitch = false;
bool RSwitch = false;
bool lSwitch = false;
//set switches
if (s_switches[1] == "-a")
{
bool aSwitch = true;
}
if (s_switches[1] == "-r")
{
bool rSwitch = true;
}
if (s_switches[1] == "-R")
{
bool RSwitch = true;
}
if (s_switches[1] == "-l")
{
bool lSwitch = true;
}
//boost::regex expr(s_filespec);
//fs::path currentPath(s_path);
//cout << currentPath << endl;
//fs::basic_directory_iterator(s_path);
show_files(s_path) ;
}
cin.ignore();
return 0;
}