diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 47dcce32b..c2feda98a 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -818,6 +818,7 @@ int InitPlatform(void) InitAssetManager(platform.app->activity->assetManager, platform.app->activity->internalDataPath); // Initialize assets manager CORE.Storage.basePath = platform.app->activity->internalDataPath; // Define base path for storage + strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1); // Define base path for media storage //---------------------------------------------------------------------------- TRACELOG(LOG_INFO, "PLATFORM: ANDROID: Initialized successfully"); diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 5dde1df67..3ebd7291c 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1759,6 +1759,7 @@ int InitPlatform(void) // Initialize storage system //---------------------------------------------------------------------------- CORE.Storage.basePath = GetWorkingDirectory(); + strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1); //---------------------------------------------------------------------------- #if defined(__NetBSD__) diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 86842140d..63cd4f8ff 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -1394,6 +1394,7 @@ int InitPlatform(void) // Initialize storage system //---------------------------------------------------------------------------- CORE.Storage.basePath = GetWorkingDirectory(); + strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1); //---------------------------------------------------------------------------- #if defined(RGFW_WAYLAND) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 03bad80f9..0b2f3851d 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -2116,6 +2116,7 @@ int InitPlatform(void) //---------------------------------------------------------------------------- // Define base path for storage CORE.Storage.basePath = SDL_GetBasePath(); // Alternative: GetWorkingDirectory(); + strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1); //---------------------------------------------------------------------------- #if defined(USING_VERSION_SDL3) diff --git a/src/platforms/rcore_desktop_win32.c b/src/platforms/rcore_desktop_win32.c index 1dadd5586..374a50bc7 100644 --- a/src/platforms/rcore_desktop_win32.c +++ b/src/platforms/rcore_desktop_win32.c @@ -1652,6 +1652,7 @@ int InitPlatform(void) // Initialize storage system //---------------------------------------------------------------------------- CORE.Storage.basePath = GetWorkingDirectory(); + strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1); //---------------------------------------------------------------------------- TRACELOG(LOG_INFO, "PLATFORM: DESKTOP: WIN32: Initialized successfully"); diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index a08a76bce..39e778c84 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -1609,6 +1609,7 @@ int InitPlatform(void) // Initialize storage system //---------------------------------------------------------------------------- CORE.Storage.basePath = GetWorkingDirectory(); + strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1); //---------------------------------------------------------------------------- #if defined(SUPPORT_DRM_CACHE) diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 36629fc69..b6e154bbe 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -597,6 +597,7 @@ int InitPlatform(void) // TODO: Initialize storage system //---------------------------------------------------------------------------- CORE.Storage.basePath = GetWorkingDirectory(); + strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1); //---------------------------------------------------------------------------- TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully"); diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index c8fe0cfe7..b94c604c1 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -1388,6 +1388,7 @@ int InitPlatform(void) // Initialize storage system //---------------------------------------------------------------------------- CORE.Storage.basePath = GetWorkingDirectory(); + strncpy(CORE.Storage.mediaPath, CORE.Storage.basePath, MAX_FILEPATH_LENGTH - 1); //---------------------------------------------------------------------------- TRACELOG(LOG_INFO, "PLATFORM: WEB: Initialized successfully"); diff --git a/src/raylib.h b/src/raylib.h index e4be11084..289b7b85e 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1096,6 +1096,7 @@ RLAPI int *LoadRandomSequence(unsigned int count, int min, int max); // Load ran RLAPI void UnloadRandomSequence(int *sequence); // Unload random values sequence // Misc. functions +RLAPI void SetMediaPath(char *path); // Set media path for external files loading RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format) RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS) RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available) diff --git a/src/rcore.c b/src/rcore.c index d06e3089b..60e3086bb 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -317,7 +317,8 @@ typedef struct CoreData { } Window; struct { - const char *basePath; // Base path for data storage + const char *basePath; // Base path for data storage + char mediaPath[MAX_FILEPATH_LENGTH]; // Media path for data storage } Storage; struct { @@ -1011,7 +1012,7 @@ void EndDrawing(void) MsfGifResult result = msf_gif_end(&gifState); - SaveFileData(TextFormat("%s/screenrec%03i.gif", CORE.Storage.basePath, screenshotCounter), result.data, (unsigned int)result.dataSize); + SaveFileData(TextFormat("%s/screenrec%03i.gif", CORE.Storage.mediaPath, screenshotCounter), result.data, (unsigned int)result.dataSize); msf_gif_free(result); TRACELOG(LOG_INFO, "SYSTEM: Finish animated GIF recording"); @@ -1909,7 +1910,7 @@ void TakeScreenshot(const char *fileName) Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; char path[512] = { 0 }; - strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, fileName)); + strcpy(path, TextFormat("%s/%s", CORE.Storage.mediaPath, fileName)); ExportImage(image, path); // WARNING: Module required: rtextures RL_FREE(imgData); @@ -1921,6 +1922,11 @@ void TakeScreenshot(const char *fileName) #endif } +void SetMediaPath(char *path) +{ + snprintf(CORE.Storage.mediaPath, MAX_FILEPATH_LENGTH, "%s", path); +} + // Setup window configuration flags (view FLAGS) // NOTE: This function is expected to be called before window creation, // because it sets up some flags for the window creation process