Skip to content

Commit

Permalink
tgbot-cpp: Use boost::filesystem for getting filename
Browse files Browse the repository at this point in the history
- A platform independent way, to fix Windows-style directory delimiters
  • Loading branch information
Royna2544 committed Feb 27, 2024
1 parent f1c2dba commit 542d759
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/types/InputFile.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "tgbot/types/InputFile.h"
#include "tgbot/tools/StringTools.h"
#include "tgbot/tools/FileTools.h"

#include <boost/filesystem.hpp>

#include <memory>
#include <string>

Expand All @@ -13,7 +14,7 @@ InputFile::Ptr InputFile::fromFile(const string& filePath, const string& mimeTyp
auto result(make_shared<InputFile>());
result->data = FileTools::read(filePath);
result->mimeType = mimeType;
result->fileName = StringTools::split(filePath, '/').back();
result->fileName = boost::filesystem::path(filePath).filename().string();
return result;
}

Expand Down

0 comments on commit 542d759

Please sign in to comment.