Skip to content

Commit 72139d8

Browse files
committed
Setup dialog for modland.com integration were unable to resolve already selected cachedir into predefined standard choices, especially on windows builds.
1 parent 97e8e1e commit 72139d8

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

filesel/modland.com/modland-com-cachedir.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
#define MAX(a,b) ((a)>(b)?(a):(b))
33
#endif
44

5+
#undef DIRSEPARATOR
6+
#ifdef _WIN32
7+
# define DIRSEPARATOR "\\"
8+
#else
9+
# define DIRSEPARATOR "/"
10+
#endif
11+
12+
513
static void modland_com_cachedir_Draw (
614
struct console_t *console,
715
const int origselected,
@@ -59,31 +67,31 @@ static void modland_com_cachedir_Draw (
5967

6068
mlTop++;
6169

62-
console->DisplayPrintf (mlTop++, mlLeft, 0x09, mlWidth, " (%.2o%c%.9o) " "%*.*o" "$OCPDATAHOME/modland.com" "%0.7o (default)",
70+
console->DisplayPrintf (mlTop++, mlLeft, 0x09, mlWidth, " (%.2o%c%.9o) " "%*.*o" "$OCPDATAHOME" DIRSEPARATOR "modland.com" "%0.7o (default)",
6371
(0==origselected) ? '*' : ' ',
6472
(0==selected) ? 7 : 0,
6573
(0==selected) ? 1 : 3);
6674
console->DisplayPrintf (mlTop++, mlLeft, 0x07, mlWidth, " => %*S", mlWidth - 8, ocpdatahome_modland_com);
6775

6876
mlTop++;
6977

70-
console->DisplayPrintf (mlTop++, mlLeft, 0x09, mlWidth, " (%.2o%c%.9o) " "%*.*o" "$HOME/modland.com%0.7o",
78+
console->DisplayPrintf (mlTop++, mlLeft, 0x09, mlWidth, " (%.2o%c%.9o) " "%*.*o" "$HOME" DIRSEPARATOR "modland.com%0.7o",
7179
(1==origselected) ? '*' : ' ',
7280
(1==selected) ? 7 : 0,
7381
(1==selected) ? 1 : 3);
7482
console->DisplayPrintf (mlTop++, mlLeft, 0x07, mlWidth, " => %*S", mlWidth - 8, home_modland_com);
7583

7684
mlTop++;
7785

78-
console->DisplayPrintf (mlTop++, mlLeft, 0x09, mlWidth, " (%.2o%c%.9o) " "%*.*o" "$OCPDATA/modland.com" "%0.7o (might not be writable)",
86+
console->DisplayPrintf (mlTop++, mlLeft, 0x09, mlWidth, " (%.2o%c%.9o) " "%*.*o" "$OCPDATA" DIRSEPARATOR "modland.com" "%0.7o (might not be writable)",
7987
(2==origselected) ? '*' : ' ',
8088
(2==selected) ? 7 : 0,
8189
(2==selected) ? 1 : 3);
8290
console->DisplayPrintf (mlTop++, mlLeft, 0x07, mlWidth, " => %*S", mlWidth - 8, ocpdata_modland_com);
8391

8492
mlTop++;
8593

86-
console->DisplayPrintf (mlTop++, mlLeft, 0x09, mlWidth, " (%.2o%c%.9o) " "%*.*o" "$TEMP/modland.com" "%0.7o (might not be system uniqe and writable)",
94+
console->DisplayPrintf (mlTop++, mlLeft, 0x09, mlWidth, " (%.2o%c%.9o) " "%*.*o" "TEMP" DIRSEPARATOR "modland.com" "%0.7o (might not be system uniqe and writable)",
8795
(3==origselected) ? '*' : ' ',
8896
(3==selected) ? 7 : 0,
8997
(3==selected) ? 1 : 3);
@@ -204,10 +212,10 @@ static void modland_com_cachedir_Save (const struct DevInterfaceAPI_t *API, int
204212
free (modland_com.cacheconfig);
205213
switch (selected)
206214
{
207-
case 0: modland_com.cacheconfig = modland_com_strdup_slash_filesystem ("$OCPDATAHOME/modland.com/"); break;
208-
case 1: modland_com.cacheconfig = modland_com_strdup_slash_filesystem ("$HOME/modland.com/"); break;
209-
case 2: modland_com.cacheconfig = modland_com_strdup_slash_filesystem ("$OCPDATA/modland.com/"); break;
210-
case 3: modland_com.cacheconfig = modland_com_strdup_slash_filesystem ("$TEMP/modland.com/"); break;
215+
case 0: modland_com.cacheconfig = modland_com_strdup_slash_filesystem ("$OCPDATAHOME" DIRSEPARATOR "modland.com"); break;
216+
case 1: modland_com.cacheconfig = modland_com_strdup_slash_filesystem ("$HOME" DIRSEPARATOR "modland.com"); break;
217+
case 2: modland_com.cacheconfig = modland_com_strdup_slash_filesystem ("$OCPDATA" DIRSEPARATOR "modland.com/"); break;
218+
case 3: modland_com.cacheconfig = modland_com_strdup_slash_filesystem ("$TEMP" DIRSEPARATOR "modland.com/"); break;
211219

212220
default:
213221
case 4:
@@ -250,28 +258,28 @@ static void modland_com_cachedir_Run (const struct DevInterfaceAPI_t *API)
250258

251259
if (((!strncmp (modland_com.cacheconfig, "~\\", 2)) ||
252260
(!strncmp (modland_com.cacheconfig, "~/" , 2))) &&
253-
(!strcmp (modland_com.cacheconfig + 2, "modland.com")))
261+
(!strcmp (modland_com.cacheconfig + 2, "modland.com" DIRSEPARATOR)))
254262
{
255263
selected = 1;
256264
} else if (((!strncmp (modland_com.cacheconfig, "$HOME\\", 6)) ||
257265
(!strncmp (modland_com.cacheconfig, "$HOME/" , 6))) &&
258-
(!strcmp (modland_com.cacheconfig + 6, "modland.com/")))
266+
(!strcmp (modland_com.cacheconfig + 6, "modland.com" DIRSEPARATOR)))
259267
{
260268
selected = 1;
261269

262270
} else if (((!strncmp (modland_com.cacheconfig, "$OCPDATAHOME\\", 13)) ||
263271
(!strncmp (modland_com.cacheconfig, "$OCPDATAHOME/", 13))) &&
264-
(!strcmp (modland_com.cacheconfig + 13, "modland.com/")))
272+
(!strcmp (modland_com.cacheconfig + 13, "modland.com" DIRSEPARATOR)))
265273
{
266274
selected = 0;
267275
} else if (((!strncmp (modland_com.cacheconfig, "$OCPDATA\\", 9)) ||
268276
(!strncmp (modland_com.cacheconfig, "$OCPDATA/", 9))) &&
269-
(!strcmp (modland_com.cacheconfig + 9, "modland.com/")))
277+
(!strcmp (modland_com.cacheconfig + 9, "modland.com" DIRSEPARATOR)))
270278
{
271279
selected = 2;
272280
} else if (((!strncmp (modland_com.cacheconfig, "$TEMP\\", 6)) ||
273281
(!strncmp (modland_com.cacheconfig, "$TEMP/", 6))) &&
274-
(!strcmp (modland_com.cacheconfig + 9, "modland.com/")))
282+
(!strcmp (modland_com.cacheconfig + 6, "modland.com" DIRSEPARATOR)))
275283
{
276284
selected = 3;
277285
} else {

0 commit comments

Comments
 (0)