Commit 2d23a4a2 authored by RomainFeron's avatar RomainFeron
Browse files

Fixed a mistake when implementing solution for files with '.' in their names....

Fixed a mistake when implementing solution for files with '.' in their names. Added a check so that the program quits when no input file was detected
parent ceac286e
......@@ -23,7 +23,7 @@ std::vector<InputFile> get_input_files(const std::string& input_dir_path) {
std::vector<std::string> split_name;
InputFile temp;
while ((dir_content=readdir(dir))){
while ((dir_content = readdir(dir))) {
current_file = dir_content->d_name;
split_name = split(current_file, ".");
......@@ -33,12 +33,14 @@ std::vector<InputFile> get_input_files(const std::string& input_dir_path) {
// Careful: this will fail if the file name contains "." ... TODO: solve this problem
if (s > 1) {
if (split_name[s - 1] == "gz" and s > 2) {
extension = "." + split_name[s - 1] + "." + split_name[s - 2];
extension = "." + split_name[s - 2] + "." + split_name[s - 1];
} else {
extension = "." + split_name[s - 1];
}
}
std::cout << current_file << " : " << extension << std::endl;
if(std::find(extensions.begin(), extensions.end(), extension) != extensions.end()) {
temp.individual_name = split_name[0];
temp.path = input_dir_path + current_file;
......@@ -48,5 +50,11 @@ std::vector<InputFile> get_input_files(const std::string& input_dir_path) {
}
}
if (files.size() == 0) {
std::cout << " ** Error: no valid input file found in input directory \"" << input_dir_path <<"\"." << std::endl;
exit(1);
}
return files;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment