diff --git pgadmin/utils/sysSettings.cpp pgadmin/utils/sysSettings.cpp index e9f270c..7301d53 100644 --- pgadmin/utils/sysSettings.cpp +++ pgadmin/utils/sysSettings.cpp @@ -2,7 +2,7 @@ // // pgAdmin III - PostgreSQL Tools // -// Copyright (C) 2002 - 2014, The pgAdmin Development Team +// Copyright (C) 2002 - 2015, The pgAdmin Development Team // This software is released under the PostgreSQL Licence // // sysSettings.cpp - Settings handling class @@ -762,35 +762,33 @@ void sysSettings::SetCanonicalLanguage(const wxLanguage &lang) ////////////////////////////////////////////////////////////////////////// wxString sysSettings::GetConfigFile(configFileName cfgname) { - if (cfgname == PGPASS) - { + wxASSERT_MSG(cfgname == sysSettings::PGPASS,wxT("Handles only pgpass configuration")); #if wxCHECK_VERSION(2, 9, 5) - wxStandardPaths &stdp = wxStandardPaths::Get(); + wxStandardPaths &stdp = wxStandardPaths::Get(); #else - wxStandardPaths stdp; + wxStandardPaths stdp; #endif - wxString fname = stdp.GetUserConfigDir(); + wxString fname; + bool bpsfile = wxGetEnv(wxT("PGPASSFILE"),&fname); + if (!bpsfile) + { + fname = stdp.GetUserConfigDir(); + } #ifdef WIN32 + if (!bpsfile) + { fname += wxT("\\postgresql"); if (!wxDirExists(fname)) - wxMkdir(fname); - switch(cfgname) - { - case PGPASS: - fname += wxT("\\pgpass.conf"); - break; - } + wxMkdir(fname); + fname += wxT("\\pgpass.conf"); + } #else - switch(cfgname) - { - case PGPASS: - fname += wxT("/.pgpass"); - break; - } + if (!bpsfile) + { + fname += wxT("/.pgpass"); + } #endif - return fname; - } - return wxT(""); + return fname; }