Add shared_folder INI option.

This commit is contained in:
sorgelig
2020-07-03 05:52:19 +08:00
parent 29e9150ca7
commit 772d3a71eb
4 changed files with 35 additions and 3 deletions

View File

@@ -119,3 +119,9 @@ sniper_mode=0
; 0 - disable MiSTer logo in Menu core
logo=1
; Custom shared folder for core supporting this feature (currently minimig only)
; Can be relative to core's home dir or absolute path.
; Path must exist before core start to use it, or it will fail.
; Make sure USB device is mounted before use shared folder on USB!
shared_folder=

View File

@@ -71,6 +71,7 @@ static const ini_var_t ini_vars[] =
{ "SNIPER_MODE", (void*)(&(cfg.sniper_mode)), UINT8, 0, 1 },
{ "BROWSE_EXPAND", (void*)(&(cfg.browse_expand)), UINT8, 0, 1 },
{ "LOGO", (void*)(&(cfg.logo)), UINT8, 0, 1 },
{ "SHARED_FOLDER", (void*)(&(cfg.shared_folder)), STRING, 0, sizeof(cfg.shared_folder) - 1 },
};
static const int nvars = (int)(sizeof(ini_vars) / sizeof(ini_var_t));

1
cfg.h
View File

@@ -50,6 +50,7 @@ typedef struct {
char video_conf_pal[1024];
char video_conf_ntsc[1024];
char font[1024];
char shared_folder[1024];
} cfg_t;
extern cfg_t cfg;

View File

@@ -16,6 +16,7 @@
#include "../../file_io.h"
#include "../../user_io.h"
#include "../../spi.h"
#include "../../cfg.h"
#include "miminig_fs_messages.h"
#define SHMEM_ADDR 0x27FF4000
@@ -235,12 +236,35 @@ static int process_request(void *reqres_buffer)
if (!baselen)
{
strcpy(basepath, HomeDir());
strcat(basepath, "/shared");
if (strlen(cfg.shared_folder))
{
if(cfg.shared_folder[0] == '/') strcpy(basepath, cfg.shared_folder);
else
{
strcpy(basepath, HomeDir());
strcat(basepath, "/");
strcat(basepath, cfg.shared_folder);
}
}
else
{
strcpy(basepath, HomeDir());
strcat(basepath, "/shared");
}
baselen = strlen(basepath);
FileCreatePath(basepath);
if (baselen && basepath[baselen - 1] == '/')
{
basepath[baselen - 1] = 0;
baselen--;
}
if(baselen) FileCreatePath(basepath);
}
// no base path => force fail
if (!baselen) rtype = ACTION_NIL;
switch (rtype)
{
case ACTION_LOCATE_OBJECT: