gets the save-file path * The save-file path is operating system specific and is typically located under the user's home directory. * This function will raise a Lua error if unable to get the save file path. * * @note Setting the environment variable `DM_SAVE_HOME` overrides the default application support path. * * @name sys.get_save_file * @param application_id
| 371 | * ``` |
| 372 | */ |
| 373 | static int Sys_GetSaveFile(lua_State* L) |
| 374 | { |
| 375 | const char* application_id = luaL_checkstring(L, 1); |
| 376 | |
| 377 | char app_support_path[1024]; |
| 378 | dmSys::Result r = dmSys::GetApplicationSavePath(application_id, app_support_path, sizeof(app_support_path)); |
| 379 | if (r != dmSys::RESULT_OK) |
| 380 | { |
| 381 | return luaL_error(L, "Unable to locate application support path for \"%s\": (%d)", application_id, r); |
| 382 | } |
| 383 | |
| 384 | const char* filename = luaL_checkstring(L, 2); |
| 385 | char* dm_home = dmSys::GetEnv("DM_SAVE_HOME"); |
| 386 | // Higher priority |
| 387 | if (dm_home) |
| 388 | { |
| 389 | dmStrlCpy(app_support_path, dm_home, sizeof(app_support_path)); |
| 390 | } |
| 391 | |
| 392 | dmStrlCat(app_support_path, dmPath::PATH_CHARACTER, sizeof(app_support_path)); |
| 393 | dmStrlCat(app_support_path, filename, sizeof(app_support_path)); |
| 394 | lua_pushstring(L, app_support_path); |
| 395 | |
| 396 | return 1; |
| 397 | } |
| 398 | |
| 399 | |
| 400 | /*# gets the application path |
nothing calls this directly
no test coverage detected