Skip to content

Commit

Permalink
Use XDG_CONFIG_HOME when available (fixes #754)
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Feb 13, 2023
1 parent 48f6933 commit 3adfb30
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ build/windows/cdogs.rc
# Linux
bin/
/share/
include/

# Visual Studio
enc_temp_folder/
Expand Down
24 changes: 15 additions & 9 deletions src/cdogs/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
This file incorporates work covered by the following copyright and
permission notice:
Copyright (c) 2013-2016, 2018-2021 Cong Xu
Copyright (c) 2013-2016, 2018-2021, 2023 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -602,18 +602,24 @@ const char *GetHomeDirectory(void)

/* GetConfigFilePath()
*
* returns a full path to a data file...
* returns a full path to a config file
*/
char cfpath[CDOGS_PATH_MAX];
const char *GetConfigFilePath(const char *name)
{
const char *homedir = GetHomeDirectory();

strcpy(cfpath, homedir);

#ifndef __EMSCRIPTEN__
strcat(cfpath, CDOGS_CFG_DIR);
#endif
const char *xdgConfigDir = getenv("XDG_CONFIG_HOME");
if (xdgConfigDir != NULL)
{
sprintf(cfpath, "%s/cdogs-sdl/", xdgConfigDir);
}
else
{
const char *homedir = GetHomeDirectory();
strcpy(cfpath, homedir);
#ifndef __EMSCRIPTEN__
strcat(cfpath, CDOGS_CFG_DIR);
#endif
}
strcat(cfpath, name);

return cfpath;
Expand Down
Empty file added src/proto/nanopb/__init__.py
Empty file.
Empty file.

0 comments on commit 3adfb30

Please sign in to comment.