Sort viewer slides by filename when traversing a directory.
Main motivation for this was convenience when rendering directories of external files (e.g. --svgs) as readdir() does not guarantee any ordering. Change-Id: I78dced834e5a3edde4a5e8e0e65ad946c7d3a3fa Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282617 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Tyler Denniston <tdenniston@google.com>
This commit is contained in:
parent
5d1c163807
commit
31dc48138c
@ -766,10 +766,21 @@ void Viewer::initSlides() {
|
||||
addSlide(SkOSPath::Basename(flag.c_str()), flag, info.fFactory);
|
||||
} else {
|
||||
// directory
|
||||
SkOSFile::Iter it(flag.c_str(), info.fExtension);
|
||||
SkString name;
|
||||
SkTArray<SkString> sortedFilenames;
|
||||
SkOSFile::Iter it(flag.c_str(), info.fExtension);
|
||||
while (it.next(&name)) {
|
||||
addSlide(name, SkOSPath::Join(flag.c_str(), name.c_str()), info.fFactory);
|
||||
sortedFilenames.push_back(name);
|
||||
}
|
||||
if (sortedFilenames.count()) {
|
||||
SkTQSort(sortedFilenames.begin(), sortedFilenames.end() - 1,
|
||||
[](const SkString& a, const SkString& b) {
|
||||
return strcmp(a.c_str(), b.c_str()) < 0;
|
||||
});
|
||||
}
|
||||
for (const SkString& filename : sortedFilenames) {
|
||||
addSlide(filename, SkOSPath::Join(flag.c_str(), filename.c_str()),
|
||||
info.fFactory);
|
||||
}
|
||||
}
|
||||
if (!dirSlides.empty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user