From 0b1623d07db963ecf3789aba7163321812cba88e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 18 Feb 2021 07:55:39 -0500 Subject: Add QUtil::path_basename --- include/qpdf/QUtil.hh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh index 769c5fd7..dd42fe1c 100644 --- a/include/qpdf/QUtil.hh +++ b/include/qpdf/QUtil.hh @@ -130,14 +130,22 @@ namespace QUtil // Write the contents of filename as a binary file to the // pipeline. QPDF_DLL - void - pipe_file(char const* filename, Pipeline* p); + void pipe_file(char const* filename, Pipeline* p); // Return a function that will send the contents of the given file // through the given pipeline as binary data. QPDF_DLL - std::function - file_provider(std::string const& filename); + std::function file_provider(std::string const& filename); + + // Return the last path element. On Windows, either / or \ are + // path separators. Otherwise, only / is a path separator. Strip + // any trailing path separators. Then, if any path separators + // remain, return everything after the last path separator. + // Otherwise, return the whole string. As a special case, if a + // string consists entirely of path separators, the first + // character is returned. + QPDF_DLL + std::string path_basename(std::string const& filename); QPDF_DLL char* copy_string(std::string const&); -- cgit v1.2.3-54-g00ecf