From 21c53823ee766c90d57a0e7d1b3b8882d0ffb4db Mon Sep 17 00:00:00 2001 From: Scott Gilbertson Date: Sat, 6 Jan 2024 18:21:59 -0500 Subject: [PATCH] Reimplemented %p template specifier to use new method, added %P specifier The %P specifier includes directories from the start of the file path, whereas the original %p specifier includes them from the end. In both cases N is from the last directory in the path, and -N is from the first directory in the path (N=1..9). --- rtgui/batchqueue.cc | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index 732580599..cb9127333 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -837,6 +837,7 @@ static inline Glib::ustring combineDirectoryNames(unsigned startIndex, unsigned // Look for N or -N in templateText at position ix, meaning "index from end" and "index from start" // For N, return Nth index from the end, and for -N return the Nth index from the start +// N is a digit 1 through 9 static inline unsigned decodePathIndex(unsigned & ix, Glib::ustring & templateText, size_t numPathElements) { unsigned pathIndex = numPathElements; // means input was invalid @@ -854,7 +855,6 @@ static inline unsigned decodePathIndex(unsigned & ix, Glib::ustring & templateTe unsigned n = templateText[ix] - '1'; if (!fromStart) { - // n=1 is the last element, n=2 is the one before that n = numPathElements - n - 1; } if (n < numPathElements) @@ -870,7 +870,6 @@ static inline unsigned decodePathIndex(unsigned & ix, Glib::ustring & templateTe Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileName, int sequence) { - std::vector pa; std::vector da; for (size_t i = 0; i < origFileName.size(); i++) { @@ -893,26 +892,8 @@ Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileNam } } - if (origFileName[0] == '/') { - pa.push_back ("/" + da[0]); - } else if (origFileName[0] == '\\') { - if (origFileName.size() > 1 && origFileName[1] == '\\') { - pa.push_back ("\\\\" + da[0]); - } else { - pa.push_back ("/" + da[0]); - } - } else { - pa.push_back (da[0]); - } - - for (size_t i = 1; i < da.size(); i++) { - pa.push_back (pa[i - 1] + "/" + da[i]); - } - // for (int i=0; i