From 67f64081d0fc3e6ff14a2882f2f18aaa0598212d Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Mon, 30 Jul 2012 09:31:04 +0000 Subject: [PATCH] - Changed unix config directory from ~/.zdoom to ~/.config/zdoom to comply with Ubuntu Software Centre guidelines. SVN r3797 (trunk) --- src/m_misc.cpp | 36 ++++++++++++++++++++++++++++++++++-- src/p_glnodes.cpp | 2 +- src/version.h | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 08149ad96..32783236e 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -340,9 +340,41 @@ FString GetUserFile (const char *file) struct stat info; path = NicePath("~/" GAME_DIR "/"); + if (stat (path, &info) == -1) { - if (mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR) == -1) + struct stat extrainfo; + + // Sanity check for ~/.config + FString configPath = NicePath("~/.config/"); + if (stat (configPath, &extrainfo) == -1) + { + if (mkdir (configPath, S_IRUSR | S_IWUSR | S_IXUSR) == -1) + { + I_FatalError ("Failed to create ~/.config directory:\n%s", strerror(errno)); + } + } + else if (!S_ISDIR(extrainfo.st_mode)) + { + I_FatalError ("~/.config must be a directory"); + } + + // This can be removed after a release or two + // Transfer the old zdoom directory to the new location + bool moved = false; + FString oldpath = NicePath("~/.zdoom/"); + if (stat (oldpath, &extrainfo) != -1) + { + if (rename(oldpath, path) == -1) + { + I_Error ("Failed to move old zdoom directory (%s) to new location (%s).", + oldpath.GetChars(), path.GetChars()); + } + else + moved = true; + } + + if (!moved && mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR) == -1) { I_FatalError ("Failed to create %s directory:\n%s", path.GetChars(), strerror (errno)); @@ -682,7 +714,7 @@ void M_ScreenShot (const char *filename) if (dirlen == 0) { #ifdef unix - autoname = "~/.zdoom/screenshots/"; + autoname = "~/" GAME_DIR "/screenshots/"; #elif defined(__APPLE__) char cpath[PATH_MAX]; FSRef folder; diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 95c078eb8..ee32df4b0 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -1088,7 +1088,7 @@ static FString GetCachePath() path += "/zdoom/cache"; #else // Don't use GAME_DIR and such so that ZDoom and its child ports can share the node cache. - path = NicePath("~/.zdoom/cache"); + path = NicePath("~/.config/zdoom/cache"); #endif return path; } diff --git a/src/version.h b/src/version.h index 00fa5371e..b8d15d1b0 100644 --- a/src/version.h +++ b/src/version.h @@ -116,7 +116,7 @@ static inline const char *MakeSaveSig() #define BUGS_FORUM_URL "http://forum.zdoom.org/index.php?c=3" #ifdef unix -#define GAME_DIR ".zdoom" +#define GAME_DIR ".config/zdoom" #elif defined(__APPLE__) #define GAME_DIR GAMENAME #else