diff options
| author | pp <pp@455248ca-bdda-0310-9134-f4ebb693071a> | 2008-03-12 15:28:21 +0000 |
|---|---|---|
| committer | pp <pp@455248ca-bdda-0310-9134-f4ebb693071a> | 2008-03-12 15:28:21 +0000 |
| commit | 77cc51bf727090aab0e91a9e30cd642497f9f18b (patch) | |
| tree | 7f73691e8532405d648db1510e46a8659c3deaff /src | |
| parent | 531177f116b52f080ad93716baf86091cc73024c (diff) | |
- 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
Diffstat (limited to 'src')
| -rw-r--r-- | src/lingot-defs.h | 5 | ||||
| -rw-r--r-- | src/lingot.c | 20 |
2 files changed, 22 insertions, 3 deletions
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. |
