diff options
| author | pp <pp@455248ca-bdda-0310-9134-f4ebb693071a> | 2008-03-12 15:28:21 +0000 |
|---|---|---|
| committer | Piotr Pawlow <pp@siedziba.pl> | 2014-03-13 21:14:08 +0100 |
| commit | f35a6831dcc444ab1fbbd6410176b049de5ae3a7 (patch) | |
| tree | 1d962bb252e458faccdb1edfaf2761f9f9eec246 | |
| parent | f82f56dd6106959f6f3bb693df664bb66e4cd070 (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
| -rw-r--r-- | src/lingot-defs.h | 5 | ||||
| -rw-r--r-- | src/lingot.c | 22 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/lingot-defs.h b/src/lingot-defs.h index a3b077c..d66d265 100644 --- a/src/lingot-defs.h +++ b/src/lingot-defs.h @@ -32,7 +32,12 @@ #define SAMPLE_TYPE int16_t #define SAMPLE_FORMAT AFMT_S16_LE +#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 d383833..39dde86 100644 --- a/src/lingot.c +++ b/src/lingot.c @@ -74,16 +74,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 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)) { @@ -105,7 +115,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; @@ -125,9 +135,13 @@ int main(int argc, char *argv[]) { if ((fp = fopen(CONFIG_FILE_NAME, "r")) == NULL) { 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. |
