Skip to content
Snippets Groups Projects
Commit 4df630d6 authored by am0ebe's avatar am0ebe
Browse files

files check stuff

parent 9597760d
No related branches found
No related tags found
No related merge requests found
{
"name": "run",
"shell_cmd": "bgs_demo -i ../../dataset/video.tar -a 100 -o ../../output -c ../../config/centerConfigFile.xml -p ../../config/camParam.xml",
"shell_cmd": "bgs_demo -i ../../dataset/video.tar -a 100 -o ../../output -c ../../config/centerConfigFile.xml -p ../../config/camParam.xml | c++filt -t",
},
{
"name": "clean",
......@@ -8,7 +8,7 @@
},
{
"name": "run: single",
"shell_cmd": "echo 'run...' && $file_base_name",
"shell_cmd": "echo 'run...' && $file_base_name | c++filt -t",
},
{
"name": "opencv: single",
......
......@@ -171,29 +171,19 @@ void parse(int argc, char** argv)
cout << "amountFiles: " << amountFiles << endl;
cout << boolalpha << "testMode: " << testMode << endl;
bool check = Tools::checkFile(camParamFile,"camParamFile") && \
Tools::checkFile(centerFile,"centerFile") && \
Tools::checkFile(inputFile,"inputFile") && \
Tools::checkDir(outputDir,"outputDir");
list<tuple <string, string, bool>> tuplelist;
tuple <string, string, bool> filedir = make_tuple("camParamFile",camParamFile,false);
tuple <string, string, bool> filedir = make_tuple("centerFile",centerFile,false);
tuple <string, string, bool> filedir = make_tuple("inputFile",inputFile,false);
tuple <string, string, bool> filedir = make_tuple("outputDir",outputDir,true);
if( checkFileDir(\
"camParamFile", camParamFile, \
"centerFile", centerFile, \
"inputFile", inputFile, \
"outputDir", outputDir) )
vector<String> x ={
"camParamFile", camParamFile,
"centerFile", centerFile,
"inputFile", inputFile,
"outputDir", outputDir
};
if( !Tools::check(x))
exit(error::config_filedir);
if(check)
exit(error::config_filedir);
Tools::maybeAppendSepToDir(outputDir);
Tools::print_ruler();
exit(1232);
exit(-1);
}
void read_camParamFile()
......
......@@ -12,43 +12,33 @@ void Tools::print_ruler()
std::cout << "######################################" << std::endl;
}
bool Tools::checkFile(std::string path, std::string name="path")
bool Tools::maybeAppendSepToDir(String& d)
{
bool check = std::filesystem::exists(path);
if (!check)
std::cerr << name << ": " << path << " [not found!] " << std::endl;
else
std::cout << name << ": " << path << std::endl;
return check;
const char SEP = std::filesystem::path::preferred_separator;
if( d.back() != SEP )
d += SEP;
}
bool Tools::checkDir(std::string& path, std::string name="path")
auto Tools::check(vector<String>& x)
{
const char SEP = std::filesystem::path::preferred_separator;
if( ! path.ends_with(SEP) )
path += SEP;
bool check = std::filesystem::exists(path);
if (!check)
{
try {
std::filesystem::create_directories(path);
std::cout << name << ": " << path << " [created!] " << std::endl;
check = true;
}
catch (std::filesystem::filesystem_error &e) {
std::cerr << name << ": " << path << " [not found + cant create it!] " << std::endl;
check = false;
}
}
else
{
std::cout << name << ": " << path << std::endl;
}
return check;
bool checkAll = true;
String name, path;
for (int i{0}; i<x.size()-1; i++)
{
name = x[i];
path = x[++i];
bool check = std::filesystem::exists(path);
if (!check)
std::cerr << name << ": " << path << " [not found!] " << std::endl;
else
std::cout << name << ": " << path << std::endl;
checkAll &= check;
}
return checkAll;
}
std::string Tools::mNzero(int i)
......
......@@ -26,8 +26,8 @@ class Tools
{
public:
static bool checkDir(std::string& path, std::string name);
static bool checkFile(std::string path, std::string name);
static void maybeAppendSepToDir(std::String& d)
static bool check(std::vector<std::String>& x)
//! print ruler
static void print_ruler();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment