- configuration directory on WIN32 is "lingot" instead of ".lingot"
- 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
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.