get proper user home dir on WIN32 and adjust folders in this case a bit

This commit is contained in:
Andrzej Rybczak
2009-03-26 20:23:47 +01:00
parent a670be05fe
commit 49a13222a3
6 changed files with 26 additions and 6 deletions

View File

@@ -468,7 +468,7 @@ void Browser::ChangeBrowseMode()
Config.local_browser = !Config.local_browser; Config.local_browser = !Config.local_browser;
ShowMessage("Browse mode: %s", Config.local_browser ? "Local filesystem" : "MPD music dir"); 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(); w->Reset();
GetDirectory(itsBrowsedDir); GetDirectory(itsBrowsedDir);
RedrawHeader = 1; RedrawHeader = 1;

View File

@@ -46,7 +46,7 @@ using std::string;
using std::vector; using std::vector;
#ifdef HAVE_CURL_CURL_H #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; bool Info::ArtistReady = 0;
#ifdef HAVE_PTHREAD_H #ifdef HAVE_PTHREAD_H

View File

@@ -42,11 +42,17 @@
#include "status.h" #include "status.h"
#include "tag_editor.h" #include "tag_editor.h"
#ifdef WIN32
# define LYRICS_FOLDER HOME_FOLDER"\\lyrics\\"
#else
# define LYRICS_FOLDER "/.lyrics"
#endif // WIN32
using namespace Global; using namespace Global;
using std::vector; using std::vector;
using std::string; using std::string;
const std::string Lyrics::Folder = home_folder + "/.lyrics"; const std::string Lyrics::Folder = home_path + LYRICS_FOLDER;
bool Lyrics::Reload = 0; bool Lyrics::Reload = 0;

View File

@@ -27,6 +27,12 @@
#include "menu.h" #include "menu.h"
#include "scrollpad.h" #include "scrollpad.h"
#ifdef WIN32
# define HOME_ENV "USERPROFILE"
#else
# define HOME_ENV "HOME"
#endif // WIN32
#ifdef HAVE_PTHREAD_H #ifdef HAVE_PTHREAD_H
# include <pthread.h> # include <pthread.h>
#else #else
@@ -41,7 +47,9 @@ typedef std::pair<std::string, std::string> string_pair;
const int ncmpcpp_window_timeout = 250; 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 #endif

View File

@@ -464,7 +464,7 @@ void ReadConfiguration(ncmpcpp_config &conf)
{ {
// if ~ is used at the beginning, replace it with user's home folder // if ~ is used at the beginning, replace it with user's home folder
if (v[0] == '~') if (v[0] == '~')
v.replace(0, 1, home_folder); v.replace(0, 1, home_path);
conf.mpd_music_dir = v + "/"; conf.mpd_music_dir = v + "/";
} }
} }

View File

@@ -26,7 +26,13 @@
#include "libmpdclient.h" #include "libmpdclient.h"
#include "ncmpcpp.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<int>::max(); const int null_key = std::numeric_limits<int>::max();
struct ncmpcpp_keys struct ncmpcpp_keys