From 8877f085b0891585125fae8c8fdc1a08c030710e Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sat, 2 Apr 2016 23:07:21 -0400 Subject: [PATCH] Peeling off folder (if provided) in utility function --- src/openalpr/support/filesystem.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/openalpr/support/filesystem.cpp b/src/openalpr/support/filesystem.cpp index b9febfd..9669cd6 100644 --- a/src/openalpr/support/filesystem.cpp +++ b/src/openalpr/support/filesystem.cpp @@ -113,8 +113,15 @@ namespace alpr std::string filenameWithoutExtension(std::string filename) { + int lastslash = filename.find_last_of("/"); + if (lastslash >= filename.size()) + lastslash = 0; + else + lastslash += 1; + int lastindex = filename.find_last_of("."); - return filename.substr(0, lastindex); + + return filename.substr(lastslash, lastindex - lastslash); } std::string get_filename_from_path(std::string file_path)