diff --git a/src/browser.cpp b/src/browser.cpp index bbc70959..b7f98acf 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -468,7 +468,7 @@ void Browser::ChangeBrowseMode() Config.local_browser = !Config.local_browser; ShowMessage("Browse mode: %s", Config.local_browser ? "Local filesystem" : "MPD music dir"); - itsBrowsedDir = Config.local_browser ? home_folder : "/"; + itsBrowsedDir = Config.local_browser ? home_path : "/"; w->Reset(); GetDirectory(itsBrowsedDir); RedrawHeader = 1; diff --git a/src/info.cpp b/src/info.cpp index a9b3f0e6..072d4f12 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -46,7 +46,7 @@ using std::string; using std::vector; #ifdef HAVE_CURL_CURL_H -const std::string Info::Folder = home_folder + "/.ncmpcpp/artists"; +const std::string Info::Folder = home_path + HOME_FOLDER"artists"; bool Info::ArtistReady = 0; #ifdef HAVE_PTHREAD_H diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 908563ed..8deced81 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -42,11 +42,17 @@ #include "status.h" #include "tag_editor.h" +#ifdef WIN32 +# define LYRICS_FOLDER HOME_FOLDER"\\lyrics\\" +#else +# define LYRICS_FOLDER "/.lyrics" +#endif // WIN32 + using namespace Global; using std::vector; using std::string; -const std::string Lyrics::Folder = home_folder + "/.lyrics"; +const std::string Lyrics::Folder = home_path + LYRICS_FOLDER; bool Lyrics::Reload = 0; diff --git a/src/ncmpcpp.h b/src/ncmpcpp.h index e945acf8..3448f524 100644 --- a/src/ncmpcpp.h +++ b/src/ncmpcpp.h @@ -27,6 +27,12 @@ #include "menu.h" #include "scrollpad.h" +#ifdef WIN32 +# define HOME_ENV "USERPROFILE" +#else +# define HOME_ENV "HOME" +#endif // WIN32 + #ifdef HAVE_PTHREAD_H # include #else @@ -41,7 +47,9 @@ typedef std::pair string_pair; const int ncmpcpp_window_timeout = 250; -const std::string home_folder = getenv("HOME") ? getenv("HOME") : ""; +const std::string home_path = getenv(HOME_ENV) ? getenv(HOME_ENV) : ""; + +#undef HOME_ENV #endif diff --git a/src/settings.cpp b/src/settings.cpp index fa9ff039..dcbe97c0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -464,7 +464,7 @@ void ReadConfiguration(ncmpcpp_config &conf) { // if ~ is used at the beginning, replace it with user's home folder if (v[0] == '~') - v.replace(0, 1, home_folder); + v.replace(0, 1, home_path); conf.mpd_music_dir = v + "/"; } } diff --git a/src/settings.h b/src/settings.h index b2a49e28..c456be43 100644 --- a/src/settings.h +++ b/src/settings.h @@ -26,7 +26,13 @@ #include "libmpdclient.h" #include "ncmpcpp.h" -const std::string config_dir = home_folder + "/.ncmpcpp/"; +#ifdef WIN32 +# define HOME_FOLDER "\\ncmpcpp\\" +#else +# define HOME_FOLDER "/.ncmpcpp/" +#endif // WIN32 + +const std::string config_dir = home_path + HOME_FOLDER; const int null_key = std::numeric_limits::max(); struct ncmpcpp_keys