From 77cc51bf727090aab0e91a9e30cd642497f9f18b Mon Sep 17 00:00:00 2001 From: pp Date: Wed, 12 Mar 2008 15:28:21 +0000 Subject: - configuration directory on WIN32 is "lingot" instead of ".lingot" - store configuration directory in APPDATA on WIN32 - mkdir() on WIN32 takes only 1 argument - get translations from "share/locale" on WIN32, which is consistent with GTK, and makes distributing easier (does not require installation) git-svn-id: https://lampka.siedziba.pl:790/svn/repos/lingot-win32@294 455248ca-bdda-0310-9134-f4ebb693071a --- src/lingot-defs.h | 5 +++++ src/lingot.c | 20 +++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lingot-defs.h b/src/lingot-defs.h index 388c1f6..36ffafa 100644 --- a/src/lingot-defs.h +++ b/src/lingot-defs.h @@ -32,7 +32,12 @@ #define SAMPLE_TYPE int16_t +#ifdef __WIN32__ +#define CONFIG_DIR_NAME "lingot/" +#else #define CONFIG_DIR_NAME ".lingot/" +#endif + #define DEFAULT_CONFIG_FILE_NAME "lingot.conf" extern char CONFIG_FILE_NAME[]; diff --git a/src/lingot.c b/src/lingot.c index 4da9f53..cc8a303 100644 --- a/src/lingot.c +++ b/src/lingot.c @@ -39,16 +39,26 @@ char CONFIG_FILE_NAME[100]; int main(int argc, char *argv[]) { + char *homedir; +#ifdef __WIN32__ + homedir = getenv("APPDATA"); +#else + homedir = getenv("HOME"); +#endif #ifdef ENABLE_NLS +#ifdef __WIN32__ + bindtextdomain (GETTEXT_PACKAGE, "share/locale"); +#else bindtextdomain (GETTEXT_PACKAGE, LINGOT_LOCALEDIR); +#endif bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif // default config file. sprintf(CONFIG_FILE_NAME, "%s/" CONFIG_DIR_NAME DEFAULT_CONFIG_FILE_NAME, - getenv("HOME")); + homedir); // TODO: indicate complete config file path if ((argc > 3) || (argc == 2)) @@ -79,7 +89,7 @@ int main(int argc, char *argv[]) switch (c) { case 'c': - sprintf(CONFIG_FILE_NAME, "%s/%s%s.conf", getenv("HOME"), + sprintf(CONFIG_FILE_NAME, "%s/%s%s.conf", homedir, CONFIG_DIR_NAME, optarg); printf("using config file %s\n", CONFIG_FILE_NAME); break; @@ -109,9 +119,13 @@ int main(int argc, char *argv[]) { char config_dir[100]; - sprintf(config_dir, "%s/.lingot/", getenv("HOME")); + sprintf(config_dir, "%s/%s", homedir, CONFIG_DIR_NAME); printf("creating directory %s ...\n", config_dir); +#ifdef __WIN32__ + mkdir(config_dir); +#else mkdir(config_dir, 0777); // creo el directorio. +#endif printf("creating file %s ...\n", CONFIG_FILE_NAME); // new configuration with default values. -- cgit v1.2.3