summaryrefslogtreecommitdiff
path: root/ui/sorting.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:19:49 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:19:49 +0200
commitc8e0e909b4a8d18319fc65434a10dc446434817c (patch)
treeeee91e7d2ce229dd043811eae8f1e2bd78061916 /ui/sorting.h
parent5.2 (diff)
downloadFreeFileSync-c8e0e909b4a8d18319fc65434a10dc446434817c.tar.gz
FreeFileSync-c8e0e909b4a8d18319fc65434a10dc446434817c.tar.bz2
FreeFileSync-c8e0e909b4a8d18319fc65434a10dc446434817c.zip
5.3
Diffstat (limited to 'ui/sorting.h')
-rw-r--r--ui/sorting.h17
1 files changed, 10 insertions, 7 deletions
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<side>())
return true; //empty rows always last
-
- const FileMapping* fileObjA = dynamic_cast<const FileMapping*>(&a);
- const FileMapping* fileObjB = dynamic_cast<const FileMapping*>(&b);
-
- if (!fileObjA)
+ if (dynamic_cast<const DirMapping*>(&a))
return false; //directories last
- else if (!fileObjB)
+ else if (dynamic_cast<const DirMapping*>(&b))
return true; //directories last
- return makeSortDirection(LessFilename(), Int2Type<ascending>())(fileObjA->getExtension<side>(), fileObjB->getExtension<side>());
+ auto getExtension = [&](const FileSystemObject& fsObj) -> Zstring
+ {
+ const Zstring& shortName = fsObj.getShortName<side>();
+ const size_t pos = shortName.rfind(Zchar('.'));
+ return pos == Zstring::npos ? Zstring() : Zstring(shortName.c_str() + pos + 1);
+ };
+
+ return makeSortDirection(LessFilename(), Int2Type<ascending>())(getExtension(a), getExtension(b));
}
bgstack15