Skip to content

Commit

Permalink
Make use of the C++17 filesystem library
Browse files Browse the repository at this point in the history
  • Loading branch information
mryndzionek committed Aug 14, 2024
1 parent 1871389 commit 5214219
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <math.h>
#include <iostream>

#include <filesystem>

namespace fs = std::filesystem;

using namespace cv;
using namespace std;

Expand Down Expand Up @@ -113,27 +117,8 @@ void preProcess(Mat src, Mat &dst)

string getOutputFileName(string path, string name)
{
std::string fname, ext;

size_t sep = path.find_last_of("\\/");
if (sep != std::string::npos)
{
path = path.substr(sep + 1, path.size() - sep - 1);

size_t dot = path.find_last_of(".");
if (dot != std::string::npos)
{
fname = path.substr(0, dot);
ext = path.substr(dot, path.size() - dot);
}
else
{
fname = path;
ext = "";
}
}

return fname + "_" + name + ext;
fs::path filePath = path;
return filePath.stem().string() + "_" + name + filePath.extension().string();
}

int main(int argc, char **argv)
Expand Down

0 comments on commit 5214219

Please sign in to comment.