From 70f54bd223b992390d113787eb473f3d7871d9ef Mon Sep 17 00:00:00 2001 From: Stas Degteff Date: Thu, 27 Oct 2005 18:31:18 +0000 Subject: [PATCH] (UNIX-like OS) see golded.cfg in /usr/local/etc/, ~/.golded/ and ~/ --- docs/notework.txt | 3 +++ golded3/gefn.h | 18 ++++++++++++++++++ golded3/geinit.cpp | 25 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/docs/notework.txt b/docs/notework.txt index c41de26..b5e75ca 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -10,6 +10,9 @@ ______________________________________________________________________ Notes for GoldED+ 1.1.5, /snapshot/ ______________________________________________________________________ +! New locations of config file for unix-like OS: ~/.golded/, ~/ and + /usr/local/etc/. + + Compile-time defines to specify config file name: GEDCFG (default is "golded.cfg") and GEDCFG2 (default is platform-depended: "gedw32.cfg", "ged2.cfg", "geddos.cfg" or nothing). diff --git a/golded3/gefn.h b/golded3/gefn.h index 9ac0d79..81b8dc9 100644 --- a/golded3/gefn.h +++ b/golded3/gefn.h @@ -96,4 +96,22 @@ #define FIDOLASTREAD "lastread" #endif +#ifndef CFGUSERPATH1 +#ifdef __UNIX__ +#define CFGUSERPATH1 "~/.golded/" +#endif +#endif + +#ifndef CFGUSERPATH2 +#ifdef __UNIX__ +#define CFGUSERPATH2 "~/" +#endif +#endif + +#ifndef CFGPATH +#ifdef __UNIX__ +#define CFGPATH "/usr/local/etc/" +#endif +#endif + #endif /* __GEFN_H__ */ diff --git a/golded3/geinit.cpp b/golded3/geinit.cpp index 351f064..e242bef 100644 --- a/golded3/geinit.cpp +++ b/golded3/geinit.cpp @@ -624,6 +624,31 @@ void Initialize(int argc, char* argv[]) { found = FindCfg(cmdlinecfg); } + #ifdef CFGUSERPATH1 + // Get it in user directory (step 1) + if(not found) { + strxcpy(cmdlinecfg, CFGUSERPATH1, sizeof(cmdlinecfg)); + getcwd(cmdlinecfg, sizeof(cmdlinecfg)); + found = FindCfg(cmdlinecfg); + } + #endif + #ifdef CFGUSERPATH2 + // Get it in user directory (step 2) + if(not found) { + strxcpy(cmdlinecfg, CFGUSERPATH2, sizeof(cmdlinecfg)); + getcwd(cmdlinecfg, sizeof(cmdlinecfg)); + found = FindCfg(cmdlinecfg); + } + #endif + #ifdef CFGPATH + // Get it in system config directory + if(not found) { + strxcpy(cmdlinecfg, CFGPATH, sizeof(cmdlinecfg)); + getcwd(cmdlinecfg, sizeof(cmdlinecfg)); + found = FindCfg(cmdlinecfg); + } + #endif + // Get it in current directory if(not found) { getcwd(cmdlinecfg, sizeof(cmdlinecfg));