From 0a52e60ececc3ed7430dacaf4e433f04d91efbce Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 18 Feb 2021 08:03:32 -0500 Subject: Use QUtil::path_basename --- examples/pdf-attach-file.cc | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'examples/pdf-attach-file.cc') diff --git a/examples/pdf-attach-file.cc b/examples/pdf-attach-file.cc index 903f30eb..0c046000 100644 --- a/examples/pdf-attach-file.cc +++ b/examples/pdf-attach-file.cc @@ -60,16 +60,7 @@ static void process(char const* infilename, char const* password, ">>")); // Create a file spec. - std::string key(attachment); - size_t pos = key.find_last_of("/\\"); - if (pos != std::string::npos) - { - key = key.substr(pos + 1); - } - if (key.empty()) - { - throw std::runtime_error("can't get last path element of attachment"); - } + std::string key = QUtil::path_basename(attachment); std::cout << whoami << ": attaching " << attachment << " as " << key << std::endl; auto fs = QPDFFileSpecObjectHelper::createFileSpec(q, key, attachment); -- cgit v1.2.3-54-g00ecf