From 772d3a71eb82b27a8ce0e02af98f3c1f3406d81a Mon Sep 17 00:00:00 2001 From: sorgelig Date: Fri, 3 Jul 2020 05:52:19 +0800 Subject: [PATCH] Add shared_folder INI option. --- MiSTer.ini | 6 ++++++ cfg.cpp | 1 + cfg.h | 1 + support/minimig/minimig_share.cpp | 30 +++++++++++++++++++++++++++--- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/MiSTer.ini b/MiSTer.ini index fe38ea3..fe8af79 100644 --- a/MiSTer.ini +++ b/MiSTer.ini @@ -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= diff --git a/cfg.cpp b/cfg.cpp index 2c33864..8624d09 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -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)); diff --git a/cfg.h b/cfg.h index b8d02b1..8d8caac 100644 --- a/cfg.h +++ b/cfg.h @@ -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; diff --git a/support/minimig/minimig_share.cpp b/support/minimig/minimig_share.cpp index 3f2be3c..6c974aa 100644 --- a/support/minimig/minimig_share.cpp +++ b/support/minimig/minimig_share.cpp @@ -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: