Skip to content

Commit

Permalink
re-added get_file_ending_with() (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
QueensGambit committed Apr 5, 2021
1 parent 55620cc commit b1eaa45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions engine/src/nn/neuralnetapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ vector<string> get_items_by_elment(const vector<string> &stringVector, const str
return returnVector;
}

string get_file_ending_with(const string& dir, const string& suffix) {
const vector<string> files = get_directory_files(dir);
const string retString = get_string_ending_with(files, suffix);
if (retString == "") {
throw invalid_argument( "The given directory at " + dir + " doesn't contain a file ending with " + suffix);
}
return retString;
}


unsigned int NeuralNetAPI::get_batch_size() const
{
Expand Down
8 changes: 8 additions & 0 deletions engine/src/nn/neuralnetapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ string get_string_ending_with(const vector<string>& stringVector, const string&
*/
vector<string> get_items_by_elment(const vector<string>& stringVector, const string& targetString, bool shouldContain);

/**
* @brief get_file_ending_with Returns the first file of a directory ending with the given suffix
* @param dir Directory where to look for the file
* @param suffix Suffix which must be at the end of the file
* @return The filename of found file excluding the directory and "" and invalid_argument if no file was found
*/
string get_file_ending_with(const string& dir, const string& suffix);


template <typename T>
/**
Expand Down

0 comments on commit b1eaa45

Please sign in to comment.