2013-05-26 00:55:41 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <string>
|
|
|
|
#include <boost/filesystem/convenience.hpp>
|
|
|
|
|
|
|
|
inline static bool set_working_dir(std::vector<std::string> args)
|
|
|
|
{
|
|
|
|
std::vector<std::string>::iterator itr = std::find(args.begin(), args.end(), "-d");
|
|
|
|
if (itr!=args.end())
|
|
|
|
{
|
2013-05-30 16:19:18 +00:00
|
|
|
unsigned dist = std::distance(args.begin(),itr);
|
2013-05-26 00:55:41 +00:00
|
|
|
if (args.size() > dist+1)
|
|
|
|
{
|
|
|
|
std::string chdir = args.at(dist+1);
|
|
|
|
bool exists = boost::filesystem::exists( chdir );
|
|
|
|
if (exists)
|
|
|
|
{
|
|
|
|
boost::filesystem::current_path(chdir);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|