From c8e0e909b4a8d18319fc65434a10dc446434817c Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:19:49 +0200 Subject: 5.3 --- ui/sorting.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'ui/sorting.h') diff --git a/ui/sorting.h b/ui/sorting.h index 807a9ce3..ad54bfbe 100644 --- a/ui/sorting.h +++ b/ui/sorting.h @@ -156,16 +156,19 @@ bool lessExtension(const FileSystemObject& a, const FileSystemObject& b) else if (b.isEmpty()) return true; //empty rows always last - - const FileMapping* fileObjA = dynamic_cast(&a); - const FileMapping* fileObjB = dynamic_cast(&b); - - if (!fileObjA) + if (dynamic_cast(&a)) return false; //directories last - else if (!fileObjB) + else if (dynamic_cast(&b)) return true; //directories last - return makeSortDirection(LessFilename(), Int2Type())(fileObjA->getExtension(), fileObjB->getExtension()); + auto getExtension = [&](const FileSystemObject& fsObj) -> Zstring + { + const Zstring& shortName = fsObj.getShortName(); + const size_t pos = shortName.rfind(Zchar('.')); + return pos == Zstring::npos ? Zstring() : Zstring(shortName.c_str() + pos + 1); + }; + + return makeSortDirection(LessFilename(), Int2Type())(getExtension(a), getExtension(b)); } -- cgit