Skip to content

Commit

Permalink
Add fsForceNextRescan(), so that .dev files can enforce the fileselec…
Browse files Browse the repository at this point in the history
…tor to refresh next time it is displayed.
  • Loading branch information
mywave82 committed Dec 14, 2024
1 parent 9e82e31 commit dccc671
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions filesel/filesystem-file-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion filesel/pfilesel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dccc671

Please sign in to comment.