Browse Source

Migrate to ~/.hush/HUSH3 for new installs, fallback to ~/.komodo/HUSH3 if that exists

pull/56/head
Duke Leto 3 years ago
parent
commit
bddd4c5cd3
  1. 18
      src/hush_utils.h
  2. 55
      src/util.cpp

18
src/hush_utils.h

@ -1369,7 +1369,7 @@ void hush_statefname(char *fname,char *symbol,char *str)
void hush_configfile(char *symbol,uint16_t rpcport)
{
static char myusername[512],mypassword[8192];
FILE *fp; uint16_t kmdport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
FILE *fp; uint16_t hushport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
if ( symbol != 0 && rpcport != 0 )
{
r = (uint32_t)time(NULL);
@ -1427,8 +1427,8 @@ void hush_configfile(char *symbol,uint16_t rpcport)
#endif
if ( (fp= fopen(fname,"rb")) != 0 )
{
if ( (kmdport= _hush_userpass(username,password,fp)) != 0 )
HUSH3_PORT = kmdport;
if ( (hushport= _hush_userpass(username,password,fp)) != 0 )
HUSH3_PORT = hushport;
sprintf(HUSHUSERPASS,"%s:%s",username,password);
fclose(fp);
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
@ -1441,15 +1441,9 @@ uint16_t hush_userpass(char *userpass,char *symbol)
{
FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[HUSH_SMART_CHAIN_MAXLEN];
userpass[0] = 0;
if ( strcmp("SPECIAL",symbol) == 0 )
{
#ifdef __APPLE__
sprintf(confname,"Something.conf");
#else
sprintf(confname,"Something.conf");
#endif
}
else sprintf(confname,"%s.conf",symbol);
sprintf(confname,"%s.conf",symbol);
hush_statefname(fname,symbol,confname);
if ( (fp= fopen(fname,"rb")) != 0 )
{

55
src/util.cpp

@ -497,15 +497,30 @@ boost::filesystem::path GetDefaultDataDir()
if ( SMART_CHAIN_SYMBOL[0] != 0 )
strcpy(symbol,SMART_CHAIN_SYMBOL);
else symbol[0] = 0;
// OLD NAMES:
// Windows < Vista: C:\Documents and Settings\Username\Application Data\Komodo
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Komodo
// Mac: ~/Library/Application Support/Komodo
// Unix: ~/.komodo
// NEW NAMES:
// Windows < Vista: C:\Documents and Settings\Username\Application Data\Hush
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Hush
// Mac: ~/Library/Application Support/Hush
// Unix: ~/.hush
// ~/.hush was actually used by the original 1.x version of Hush, but we will
// only make subdirectories inside of it, so we won't be able to overwrite
// an old wallet.dat from the Ice Ages :)
#ifdef _WIN32
// Windows
if ( symbol[0] == 0 )
return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo";
else return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo" / symbol;
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo" / symbol;
if(fs::is_directory(pathRet)) {
// legacy directory, use that
} else {
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Hush" / symbol;
}
return pathRet;
#else
fs::path pathRet;
char* pszHome = getenv("HOME");
@ -517,19 +532,31 @@ boost::filesystem::path GetDefaultDataDir()
// Mac
pathRet /= "Library/Application Support";
TryCreateDirectory(pathRet);
if ( symbol[0] == 0 )
return pathRet / "Komodo";
else
{
pathRet /= "Komodo";
TryCreateDirectory(pathRet);
return pathRet / symbol;
fs::path tmppath;
tmppath = pathRet;
tmppath /= "Komodo";
if(fs::is_directory(pathRet)) {
//legacy directory, use that
TryCreateDirectory(tmppath);
return tmppath / symbol;
} else {
// New directory :)
tmppath = pathRet;
tmppath /= "Hush";
TryCreateDirectory(tmppath);
return tmppath / symbol;
}
#else
// Unix
if ( symbol[0] == 0 )
return pathRet / ".komodo";
else return pathRet / ".komodo" / symbol;
fs::path tmppath = pathRet / ".komodo" / symbol;
if(fs::is_directory(tmppath)) {
// legacy directory, use that for backward compat
return tmppath;
} else {
// New directory :)
tmppath = pathRet / ".hush" / symbol;
return tmppath;
}
#endif
#endif
}
@ -638,8 +665,6 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
path /= BaseParams().DataDir();
fs::create_directories(path);
//std::string assetpath = path + "/assets";
//boost::filesystem::create_directory(assetpath);
return path;
}

Loading…
Cancel
Save