From 08c53f0b685f3afc1836b85917a8dd203fb6857b Mon Sep 17 00:00:00 2001 From: sorgelig Date: Sun, 29 Sep 2019 06:07:04 +0800 Subject: [PATCH] file_io: some cleanup. --- file_io.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/file_io.cpp b/file_io.cpp index 0e40807..981dc80 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -1231,7 +1231,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons if (flist_nDirEntries() == 0) // directory is empty so there is no point in searching for any entry return 0; - if (mode == SCANF_END) + if (mode == SCANF_END || (mode == SCANF_PREV && iSelectedEntry <= 0)) { iSelectedEntry = flist_nDirEntries() - 1; iFirstEntry = iSelectedEntry - OsdGetSize() + 1; @@ -1247,7 +1247,9 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons } else { - ScanDirectory(path, SCANF_INIT, extension, options, prefix); // jump to first visible item + // jump to first visible item + iFirstEntry = 0; + iSelectedEntry = 0; } return 0; } @@ -1258,10 +1260,6 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons iSelectedEntry--; if (iSelectedEntry < iFirstEntry) iFirstEntry = iSelectedEntry; } - else - { - ScanDirectory(path, SCANF_END, extension, options, prefix); // jump to last visible item - } return 0; } else if (mode == SCANF_NEXT_PAGE)