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

files check stuff

parent 9597760d
Branches
No related tags found
No related merge requests found
{ {
"name": "run", "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", "name": "clean",
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
}, },
{ {
"name": "run: single", "name": "run: single",
"shell_cmd": "echo 'run...' && $file_base_name", "shell_cmd": "echo 'run...' && $file_base_name | c++filt -t",
}, },
{ {
"name": "opencv: single", "name": "opencv: single",
......
...@@ -171,29 +171,19 @@ void parse(int argc, char** argv) ...@@ -171,29 +171,19 @@ void parse(int argc, char** argv)
cout << "amountFiles: " << amountFiles << endl; cout << "amountFiles: " << amountFiles << endl;
cout << boolalpha << "testMode: " << testMode << endl; cout << boolalpha << "testMode: " << testMode << endl;
bool check = Tools::checkFile(camParamFile,"camParamFile") && \ vector<String> x ={
Tools::checkFile(centerFile,"centerFile") && \ "camParamFile", camParamFile,
Tools::checkFile(inputFile,"inputFile") && \ "centerFile", centerFile,
Tools::checkDir(outputDir,"outputDir"); "inputFile", inputFile,
"outputDir", outputDir
list<tuple <string, string, bool>> tuplelist; };
tuple <string, string, bool> filedir = make_tuple("camParamFile",camParamFile,false); if( !Tools::check(x))
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) )
exit(error::config_filedir); exit(error::config_filedir);
if(check) Tools::maybeAppendSepToDir(outputDir);
exit(error::config_filedir);
Tools::print_ruler(); Tools::print_ruler();
exit(1232); exit(-1);
} }
void read_camParamFile() void read_camParamFile()
......
...@@ -12,43 +12,33 @@ void Tools::print_ruler() ...@@ -12,43 +12,33 @@ void Tools::print_ruler()
std::cout << "######################################" << std::endl; std::cout << "######################################" << std::endl;
} }
bool Tools::maybeAppendSepToDir(String& d)
bool Tools::checkFile(std::string path, std::string name="path")
{ {
bool check = std::filesystem::exists(path); const char SEP = std::filesystem::path::preferred_separator;
if (!check) if( d.back() != SEP )
std::cerr << name << ": " << path << " [not found!] " << std::endl; d += SEP;
else
std::cout << name << ": " << path << std::endl;
return check;
} }
bool Tools::checkDir(std::string& path, std::string name="path") auto Tools::check(vector<String>& x)
{ {
const char SEP = std::filesystem::path::preferred_separator; bool checkAll = true;
if( ! path.ends_with(SEP) ) String name, path;
path += SEP;
for (int i{0}; i<x.size()-1; i++)
bool check = std::filesystem::exists(path); {
if (!check) name = x[i];
{ path = x[++i];
try {
std::filesystem::create_directories(path); bool check = std::filesystem::exists(path);
std::cout << name << ": " << path << " [created!] " << std::endl; if (!check)
check = true; std::cerr << name << ": " << path << " [not found!] " << std::endl;
} else
catch (std::filesystem::filesystem_error &e) { std::cout << name << ": " << path << std::endl;
std::cerr << name << ": " << path << " [not found + cant create it!] " << std::endl;
check = false; checkAll &= check;
} }
}
else return checkAll;
{
std::cout << name << ": " << path << std::endl;
}
return check;
} }
std::string Tools::mNzero(int i) std::string Tools::mNzero(int i)
......
...@@ -26,8 +26,8 @@ class Tools ...@@ -26,8 +26,8 @@ class Tools
{ {
public: public:
static bool checkDir(std::string& path, std::string name); static void maybeAppendSepToDir(std::String& d)
static bool checkFile(std::string path, std::string name); static bool check(std::vector<std::String>& x)
//! print ruler //! print ruler
static void 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