comparison th_file.c @ 485:4a3d561d5406

Return empty directory paths under Windows if we can't retrieve AppData directory in th_get_home_dir() and th_get_data_dir().
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 04 May 2019 03:00:23 +0300
parents 85039ab7e6ab
children 3a852e9f70a6
comparison
equal deleted inserted replaced
484:58b744131b86 485:4a3d561d5406
25 { 25 {
26 #if defined(TH_PLAT_WINDOWS) 26 #if defined(TH_PLAT_WINDOWS)
27 char tmpPath[MAX_PATH]; 27 char tmpPath[MAX_PATH];
28 if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK) 28 if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK)
29 return th_strdup(tmpPath); 29 return th_strdup(tmpPath);
30 else
31 return th_strdup("");
32
30 #elif defined(TH_PLAT_DOS) 33 #elif defined(TH_PLAT_DOS)
31 return th_strdup("C:\\"); 34 return th_strdup("C:\\");
32 #else 35 #else
33 return th_strdup(getenv("HOME")); 36 return th_strdup(getenv("HOME"));
34 #endif 37 #endif
39 { 42 {
40 #if defined(TH_PLAT_WINDOWS) 43 #if defined(TH_PLAT_WINDOWS)
41 char tmpPath[MAX_PATH]; 44 char tmpPath[MAX_PATH];
42 if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK) 45 if (SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, tmpPath) == S_OK)
43 return th_strdup(tmpPath); 46 return th_strdup(tmpPath);
47 else
48 return th_strdup("");
49
44 #elif defined(TH_PLAT_DOS) 50 #elif defined(TH_PLAT_DOS)
45 return th_strdup("C:\\"); 51 return th_strdup("C:\\");
46 #else 52 #else
47 return th_strdup(getenv("HOME")); 53 return th_strdup(getenv("HOME"));
48 #endif 54 #endif