From dccc6712c017f02c717b1cd2e92ddcdd5e242f13 Mon Sep 17 00:00:00 2001 From: Stian Skjelstad Date: Fri, 16 Aug 2024 22:28:30 +0200 Subject: [PATCH] Add fsForceNextRescan(), so that .dev files can enforce the fileselector to refresh next time it is displayed. --- filesel/filesystem-file-dev.h | 1 + filesel/pfilesel.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/filesel/filesystem-file-dev.h b/filesel/filesystem-file-dev.h index dc370e35..36678d58 100644 --- a/filesel/filesystem-file-dev.h +++ b/filesel/filesystem-file-dev.h @@ -32,6 +32,7 @@ struct DevInterfaceAPI_t int (*KeyHelpDisplay) (void); /* Draws the keyboard shortcut list and polls keyboard. Call for each draw-iteration until it returns zero */ void (*fsDraw) (void); /* Draws the filesystem browser, great for virtual devices that has a dialog */ + void (*fsForceNextRescan) (void); /* Next time fsFileSelect() is oalled, enforce a rescan */ }; struct IOCTL_DevInterface diff --git a/filesel/pfilesel.c b/filesel/pfilesel.c index 11fd457f..42959f6b 100644 --- a/filesel/pfilesel.c +++ b/filesel/pfilesel.c @@ -121,6 +121,8 @@ static struct interfacestruct *plInterfaces; static struct DevInterfaceAPI_t DevInterfaceAPI; +static void fsForceNextRescan(void); /* Next time fsFileSelect() is called, force a rescan */ + struct fsReadDir_token_t { #if 0 @@ -732,11 +734,20 @@ int fsFilesLeft(void) /* op = 0, move cursor to the top * op = 1, maintain current cursor position */ + +static int fsFileSelect_ForceRescan = 0; +static void fsForceNextRescan(void) /* Next time fsFileSelect() is called, force a rescan */ +{ + fsFileSelect_ForceRescan = 1; +} + static char fsScanDir (int op) { uint32_t dirdb_ref = DIRDB_CLEAR; int pos; + fsFileSelect_ForceRescan = 0; + /* if we are to maintain the old position, store both the dirdb reference and the position as fall-back */ if (op == 1) { @@ -1117,7 +1128,8 @@ static struct DevInterfaceAPI_t DevInterfaceAPI = cpiKeyHelp, cpiKeyHelpClear, cpiKeyHelpDisplay, - fsDraw + fsDraw, + fsForceNextRescan }; static int VirtualInterfaceInit (struct moduleinfostruct *info, struct ocpfilehandle_t *fi, const struct cpifaceplayerstruct *cp) @@ -3200,6 +3212,9 @@ signed int fsFileSelect(void) if (!currentdir->num) { /* this is true the very first time we execute */ fsScanDir(0); + } else if (fsFileSelect_ForceRescan) + { + fsScanDir(1); } plSetTextMode(fsScrType);