Get export directory for Windows

This commit is contained in:
dolphin6k 2020-08-16 17:00:58 +09:00
parent bbf795209d
commit 31fa1af9a5
3 changed files with 30 additions and 3 deletions

View file

@ -63,9 +63,10 @@ new_trie(int degree, int *nkeys)
static void static void
del_trie(Node *root, int degree) del_trie(Node *root, int degree)
{ {
int i;
if (!root) if (!root)
return; return;
for (int i = 0; i < degree; i++) for (i = 0; i < degree; i++)
del_trie(root->children[i], degree); del_trie(root->children[i], degree);
free(root); free(root);
} }

View file

@ -1319,7 +1319,9 @@ static void handle_motioners(int oldpos_x, int oldpos_y, int motioner, int hatmo
static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_y, SDL_Rect real_r_tools); static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_y, SDL_Rect real_r_tools);
char * get_xdg_user_dir(const char * dir_type, const char * fallback); char * get_xdg_user_dir(const char * dir_type, const char * fallback);
#ifdef WIN32
extern char * GetUserImageDir(void);
#endif
/* Magic tools API and tool handles: */ /* Magic tools API and tool handles: */
@ -22843,12 +22845,15 @@ static void setup_config(char *argv[])
else else
{ {
/* FIXME: Need assist for: /* FIXME: Need assist for:
* _WIN32
* __BEOS__ * __BEOS__
* __HAIKU__ * __HAIKU__
* __APPLE__ * __APPLE__
*/ */
#ifdef WIN32
picturesdir = GetUserImageDir();
#else
picturesdir = get_xdg_user_dir("PICTURES", "Pictures"); picturesdir = get_xdg_user_dir("PICTURES", "Pictures");
#endif
safe_snprintf(str, sizeof(str), "%s/TuxPaint", picturesdir); safe_snprintf(str, sizeof(str), "%s/TuxPaint", picturesdir);
free(picturesdir); free(picturesdir);
exportdir = strdup(str); exportdir = strdup(str);

View file

@ -597,6 +597,27 @@ char *GetSystemFontDir(void)
return strdup("C:\\WINDOWS\\FONTS"); return strdup("C:\\WINDOWS\\FONTS");
} }
/**
*
* Returns heap string containing user's image directory.
*
* @return user's image dir
*/
char *GetUserImageDir(void)
{
char path[MAX_PATH];
const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
const char *option = "My Pictures";
HRESULT hr = S_OK;
if (SUCCEEDED(hr = ReadRegistry(key, option, path, sizeof(path))))
{
remove_slash(path);
return strdup(path);
}
return strdup("C:\\Pictures");
}
/* /*
Returns heap string containing user temp directory. Returns heap string containing user temp directory.
E.g. C:\Documents and Settings\jfp\Local Settings\Temp E.g. C:\Documents and Settings\jfp\Local Settings\Temp