Author Topic: Proposed SB change to config file path in Windows...  (Read 200 times)

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Proposed SB change to config file path in Windows...
« on: October 09, 2018, 06:59:08 AM »
In looking into how to make SB completely portable, I'd like to propose the following change for Windows:

Instead of having the path to the config file stored in the Registry, or using a hard-coded path to the Windows folder, use the SCRIBACONF environment variable instead like the non-Windows version can.

In conftree.c, change the cft_GetConfigFileName function to the following:

Code: C
  1. int cft_GetConfigFileName(ptConfigTree pCT,
  2.                           char **ppszConfigFile,
  3.                           char *env,/* environment variable or registry key on win32 */
  4.                           char *DefaultFileName
  5.   ){
  6. /*noverbatim
  7. This function is T<static> and can not be called from outside of this module.
  8. CUT*/
  9.  
  10. #if _WIN32
  11.   char *s = getenv("SCRIBACONF");
  12. #else
  13.   char *s = getenv(env);
  14. #endif
  15.   if( s == NULL ){
  16.     *ppszConfigFile = ALLOC(strlen(DefaultFileName)+1);
  17.     if( *ppszConfigFile == NULL )return CFT_ERROR_MEMORY;
  18.     strcpy(*ppszConfigFile,DefaultFileName);
  19.     return 0;
  20.     }
  21.   *ppszConfigFile = ALLOC(strlen(s)+1);
  22.   if( *ppszConfigFile == NULL )return CFT_ERROR_MEMORY;
  23.   strcpy(*ppszConfigFile,s);
  24.   return 0;
  25. }
  26.  

Then all you need to do is set SCRIBACONF to the path to the config file and you're set.

AIR.

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Proposed SB change to config file path in Windows...
« Reply #1 on: October 09, 2018, 09:36:07 AM »
Great idea!

+1