What changed
Bitcoin v0.3.0 → v0.3.1
Release commit message: version 0.3.1 release
Full source: v0.3.0. Previous diff: v0.2.13 → v0.3.0. Next: v0.3.1 → v0.3.2.
- db.cpp modified · +2 −0
- headers.h modified · +5 −0
- init.cpp modified · +92 −49
- irc.cpp modified · +4 −0
- main.cpp modified · +31 −18
- main.h modified · +1 −0
- makefile.unix modified · +4 −4
- rpc.cpp modified · +12 −10
- serialize.h modified · +1 −1
- setup.nsi modified · +3 −3
- ui.cpp modified · +23 −4
- uibase.cpp modified · +1 −1
- uibase.h modified · +1 −1
- util.cpp modified · +71 −12
- util.h modified · +12 −7
db.cpp (modified)
1--- v0.3.0/db.cpp2+++ v0.3.1/db.cpp3@@ -592,6 +592,8 @@4 else if (strType == "version")5 {6 ssValue >> nFileVersion;7+ if (nFileVersion == 10300)8+ nFileVersion = 300;9 }10 else if (strType == "setting")11 {
headers.h (modified)
1--- v0.3.0/headers.h2+++ v0.3.1/headers.h3@@ -58,7 +58,12 @@4 #include <boost/bind.hpp>5 #include <boost/function.hpp>6 #include <boost/filesystem.hpp>7+#include <boost/filesystem/fstream.hpp>8 #include <boost/algorithm/string.hpp>9+#include <boost/interprocess/sync/interprocess_mutex.hpp>10+#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>11+#include <boost/date_time/gregorian/gregorian_types.hpp>12+#include <boost/date_time/posix_time/posix_time_types.hpp>13 14 #ifdef __WXMSW__15 #include <windows.h>
init.cpp (modified)
1--- v0.3.0/init.cpp2+++ v0.3.1/init.cpp3@@ -59,40 +59,6 @@4 //5 6 #ifdef __WXMSW__7-typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);8-9-string MyGetSpecialFolderPath(int nFolder, bool fCreate)10-{11- char pszPath[MAX_PATH+100] = "";12-13- // SHGetSpecialFolderPath is not usually available on NT 4.014- HMODULE hShell32 = LoadLibraryA("shell32.dll");15- if (hShell32)16- {17- PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =18- (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");19- if (pSHGetSpecialFolderPath)20- (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);21- FreeModule(hShell32);22- }23-24- // Backup option25- if (pszPath[0] == '\0')26- {27- if (nFolder == CSIDL_STARTUP)28- {29- strcpy(pszPath, getenv("USERPROFILE"));30- strcat(pszPath, "\\Start Menu\\Programs\\Startup");31- }32- else if (nFolder == CSIDL_APPDATA)33- {34- strcpy(pszPath, getenv("APPDATA"));35- }36- }37-38- return pszPath;39-}40-41 string StartupShortcutPath()42 {43 return MyGetSpecialFolderPath(CSIDL_STARTUP, true) + "\\Bitcoin.lnk";44@@ -100,7 +66,7 @@45 46 bool GetStartOnSystemStartup()47 {48- return wxFileExists(StartupShortcutPath());49+ return filesystem::exists(StartupShortcutPath().c_str());50 }51 52 void SetStartOnSystemStartup(bool fAutoStart)53@@ -149,9 +115,86 @@54 CoUninitialize();55 }56 }57+58+#elif defined(__WXGTK__)59+60+//61+// Follow the Desktop Application Autostart Spec:62+// http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html63+//64+65+boost::filesystem::path GetAutostartDir()66+{67+ namespace fs = boost::filesystem;68+69+ char* pszConfigHome = getenv("XDG_CONFIG_HOME");70+ if (pszConfigHome) return fs::path(pszConfigHome) / fs::path("autostart");71+ char* pszHome = getenv("HOME");72+ if (pszHome) return fs::path(pszHome) / fs::path(".config/autostart");73+ return fs::path();74+}75+76+boost::filesystem::path GetAutostartFilePath()77+{78+ return GetAutostartDir() / boost::filesystem::path("bitcoin.desktop");79+}80+81+bool GetStartOnSystemStartup()82+{83+ boost::filesystem::ifstream optionFile(GetAutostartFilePath());84+ if (!optionFile.good())85+ return false;86+ // Scan through file for "Hidden=true":87+ string line;88+ while (!optionFile.eof())89+ {90+ getline(optionFile, line);91+ if (line.find("Hidden") != string::npos &&92+ line.find("true") != string::npos)93+ return false;94+ }95+ optionFile.close();96+97+ return true;98+}99+100+void SetStartOnSystemStartup(bool fAutoStart)101+{102+ if (!fAutoStart)103+ {104+ unlink(GetAutostartFilePath().native_file_string().c_str());105+ }106+ else107+ {108+ boost::filesystem::create_directories(GetAutostartDir());109+110+ boost::filesystem::ofstream optionFile(GetAutostartFilePath(), ios_base::out|ios_base::trunc);111+ if (!optionFile.good())112+ {113+ wxMessageBox(_("Cannot write autostart/bitcoin.desktop file"), "Bitcoin");114+ return;115+ }116+ // Write a bitcoin.desktop file to the autostart directory:117+ char pszExePath[MAX_PATH+1];118+ memset(pszExePath, 0, sizeof(pszExePath));119+ readlink("/proc/self/exe", pszExePath, sizeof(pszExePath)-1);120+ optionFile << "[Desktop Entry]\n";121+ optionFile << "Type=Application\n";122+ optionFile << "Name=Bitcoin\n";123+ optionFile << "Exec=" << pszExePath << "\n";124+ optionFile << "Terminal=false\n";125+ optionFile << "Hidden=false\n";126+ optionFile.close();127+ }128+}129 #else130+131+// TODO: OSX startup stuff; see:132+// http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/CustomLogin.html133+134 bool GetStartOnSystemStartup() { return false; }135 void SetStartOnSystemStartup(bool fAutoStart) { }136+137 #endif138 139 140@@ -166,7 +209,7 @@141 //142 143 // Define a new application144-class CMyApp: public wxApp145+class CMyApp : public wxApp146 {147 public:148 wxLocale m_locale;149@@ -216,7 +259,10 @@150 #ifdef __WXMSW__151 if (str.size() >= 1 && str[0] == '/')152 str[0] = '-';153- str = str.MakeLower();154+ char pszLower[MAX_PATH];155+ strlcpy(pszLower, str.c_str(), sizeof(pszLower));156+ strlwr(pszLower);157+ str = pszLower;158 #endif159 // haven't decided which argument to use for this yet160 if (str == "-daemon" || str == "-d" || str == "start")161@@ -356,18 +402,14 @@162 " -daemon \t " + _("Run in the background as a daemon and accept commands\n") +163 " -? \t " + _("This help message\n");164 165-166- if (fWindows && fGUI)167- {168- // Tabs make the columns line up in the message box169- wxMessageBox(strUsage, "Bitcoin", wxOK);170- }171- else172- {173- // Remove tabs174- strUsage.Replace("\t", "");175- fprintf(stderr, "%s", ((string)strUsage).c_str());176- }177+#if defined(__WXMSW__) && wxUSE_GUI178+ // Tabs make the columns line up in the message box179+ wxMessageBox(strUsage, "Bitcoin", wxOK);180+#else181+ // Remove tabs182+ strUsage.Replace("\t", "");183+ fprintf(stderr, "%s", ((string)strUsage).c_str());184+#endif185 return false;186 }187 188@@ -386,6 +428,7 @@189 printf("Bitcoin version %d.%d.%d%s beta, OS version %s\n", VERSION/10000, (VERSION/100)%100, VERSION%100, pszSubVer, ((string)wxGetOsDescription()).c_str());190 printf("System default language is %d %s\n", m_locale.GetSystemLanguage(), ((string)m_locale.GetSysName()).c_str());191 printf("Language file %s (%s)\n", (string("locale/") + (string)m_locale.GetCanonicalName() + "/LC_MESSAGES/bitcoin.mo").c_str(), ((string)m_locale.GetLocale()).c_str());192+ printf("Default data directory %s\n", GetDefaultDataDir().c_str());193 194 if (mapArgs.count("-loadblockindextest"))195 {
irc.cpp (modified)
1--- v0.3.0/irc.cpp2+++ v0.3.1/irc.cpp3@@ -158,6 +158,10 @@4 5 void ThreadIRCSeed(void* parg)6 {7+ if (mapArgs.count("-connect"))8+ return;9+ if (mapArgs.count("-noirc"))10+ return;11 printf("ThreadIRCSeed started\n");12 int nErrorWait = 10;13 int nRetryWait = 10;
main.cpp (modified)
1--- v0.3.0/main.cpp2+++ v0.3.1/main.cpp3@@ -1477,7 +1477,10 @@4 if (nFreeBytesAvailable < (int64)15000000 + nAdditionalBytes)5 {6 fShutdown = true;7+ printf("*** %s***\n", _("Warning: Disk space is low "));8+#if wxUSE_GUI9 ThreadSafeMessageBox(_("Warning: Disk space is low "), "Bitcoin", wxOK | wxICON_EXCLAMATION);10+#endif11 CreateThread(Shutdown, NULL);12 return false;13 }14@@ -2541,13 +2544,13 @@15 void BitcoinMiner()16 {17 printf("BitcoinMiner started\n");18+ SetThreadPriority(THREAD_PRIORITY_LOWEST);19 20 CKey key;21 key.MakeNewKey();22 CBigNum bnExtraNonce = 0;23 while (fGenerateBitcoins)24 {25- SetThreadPriority(THREAD_PRIORITY_LOWEST);26 Sleep(50);27 if (fShutdown)28 return;29@@ -2607,6 +2610,9 @@30 CTransaction& tx = (*mi).second;31 if (tx.IsCoinBase() || !tx.IsFinal())32 continue;33+ unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK);34+ if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE - 10000)35+ continue;36 37 // Transaction fee based on block size38 int64 nMinFee = tx.GetMinFee(nBlockSize);39@@ -2617,7 +2623,7 @@40 swap(mapTestPool, mapTestPoolTmp);41 42 pblock->vtx.push_back(tx);43- nBlockSize += ::GetSerializeSize(tx, SER_NETWORK);44+ nBlockSize += nTxSize;45 vfAlreadyAdded[n] = true;46 fFoundSomething = true;47 }48@@ -2713,25 +2719,32 @@49 if ((++tmp.block.nNonce & nMask) == 0)50 {51 // Meter hashes/sec52- static int64 nHashCounter;53- static int64 nLastTick;54- if (nLastTick == 0)55- nLastTick = GetTimeMillis();56+ static int64 nTimerStart;57+ static int nHashCounter;58+ if (nTimerStart == 0)59+ nTimerStart = GetTimeMillis();60 else61- nHashCounter += nMask + 1;62- if (GetTimeMillis() - nLastTick > 4000)63+ nHashCounter++;64+ if (GetTimeMillis() - nTimerStart > 4000)65 {66- double dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nLastTick);67- nLastTick = GetTimeMillis();68- nHashCounter = 0;69- string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0);70- UIThreadCall(bind(CalledSetStatusBar, strStatus, 0));71- static int64 nLogTime;72- if (GetTime() - nLogTime > 30 * 60)73+ static CCriticalSection cs;74+ CRITICAL_BLOCK(cs)75 {76- nLogTime = GetTime();77- printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str());78- printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0);79+ if (GetTimeMillis() - nTimerStart > 4000)80+ {81+ double dHashesPerSec = 1000.0 * (nMask+1) * nHashCounter / (GetTimeMillis() - nTimerStart);82+ nTimerStart = GetTimeMillis();83+ nHashCounter = 0;84+ string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0);85+ UIThreadCall(bind(CalledSetStatusBar, strStatus, 0));86+ static int64 nLogTime;87+ if (GetTime() - nLogTime > 30 * 60)88+ {89+ nLogTime = GetTime();90+ printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str());91+ printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0);92+ }93+ }94 }95 }96
main.h (modified)
1--- v0.3.0/main.h2+++ v0.3.1/main.h3@@ -15,6 +15,7 @@4 class CKeyItem;5 6 static const unsigned int MAX_SIZE = 0x02000000;7+static const unsigned int MAX_BLOCK_SIZE = 1000000;8 static const int64 COIN = 100000000;9 static const int64 CENT = 1000000;10 static const int COINBASE_MATURITY = 100;
makefile.unix (modified)
1--- v0.3.0/makefile.unix2+++ v0.3.1/makefile.unix3@@ -23,8 +23,8 @@4 -Wl,-Bstatic \5 -l boost_system -l boost_filesystem \6 -l db_cxx \7+ -l crypto \8 -Wl,-Bdynamic \9- -l crypto \10 -l gthread-2.011 12 WXDEFS=-D__WXGTK__ -DNOPCH13@@ -68,7 +68,7 @@14 15 16 clean:17- -rm obj/*.o18- -rm obj/nogui/*.o19- -rm headers.h.gch20+ -rm -f obj/*.o21+ -rm -f obj/nogui/*.o22+ -rm -f headers.h.gch23
rpc.cpp (modified)
1--- v0.3.0/rpc.cpp2+++ v0.3.1/rpc.cpp3@@ -927,20 +927,22 @@4 string strResult = (result.type() == str_type ? result.get_str() : write_string(result, true));5 if (result.type() != null_type)6 {7- if (fWindows && fGUI)8- // Windows GUI apps can't print to command line,9- // so settle for a message box yuck10- MyMessageBox(strResult.c_str(), "Bitcoin", wxOK);11- else12- fprintf(stdout, "%s\n", strResult.c_str());13+#if defined(__WXMSW__) && wxUSE_GUI14+ // Windows GUI apps can't print to command line,15+ // so settle for a message box yuck16+ MyMessageBox(strResult.c_str(), "Bitcoin", wxOK);17+#else18+ fprintf(stdout, "%s\n", strResult.c_str());19+#endif20 }21 return 0;22 }23 catch (std::exception& e) {24- if (fWindows && fGUI)25- MyMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK);26- else27- fprintf(stderr, "error: %s\n", e.what());28+#if defined(__WXMSW__) && wxUSE_GUI29+ MyMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK);30+#else31+ fprintf(stderr, "error: %s\n", e.what());32+#endif33 } catch (...) {34 PrintException(NULL, "CommandLineRPC()");35 }
serialize.h (modified)
1--- v0.3.0/serialize.h2+++ v0.3.1/serialize.h3@@ -19,7 +19,7 @@4 class CDataStream;5 class CAutoFile;6 7-static const int VERSION = 300;8+static const int VERSION = 301;9 static const char* pszSubVer = "";10 11
setup.nsi (modified)
1--- v0.3.0/setup.nsi2+++ v0.3.1/setup.nsi3@@ -7,7 +7,7 @@4 5 # General Symbol Definitions6 !define REGKEY "SOFTWARE\$(^Name)"7-!define VERSION 0.3.08+!define VERSION 0.3.19 !define COMPANY "Bitcoin project"10 !define URL http://www.bitcoin.org/11 12@@ -42,12 +42,12 @@13 !insertmacro MUI_LANGUAGE English14 15 # Installer attributes16-OutFile bitcoin-0.3.0-win32-setup.exe17+OutFile bitcoin-0.3.1-win32-setup.exe18 InstallDir $PROGRAMFILES\Bitcoin19 CRCCheck on20 XPStyle on21 ShowInstDetails show22-VIProductVersion 0.3.0.023+VIProductVersion 0.3.1.024 VIAddVersionKey ProductName Bitcoin25 VIAddVersionKey ProductVersion "${VERSION}"26 VIAddVersionKey CompanyName "${COMPANY}"
ui.cpp (modified)
1--- v0.3.0/ui.cpp2+++ v0.3.1/ui.cpp3@@ -375,14 +375,19 @@4 // to get rid of the deprecated warning. Just ignore it.5 if (!event.Iconized())6 fClosedToTray = false;7-//#ifdef __WXMSW__8+#ifdef __WXGTK__9+ if (mapArgs.count("-minimizetotray")) {10+#endif11 // The tray icon sometimes disappears on ubuntu karmic12 // Hiding the taskbar button doesn't work cleanly on ubuntu lucid13+ // Reports of CPU peg on 64-bit linux14 if (fMinimizeToTray && event.Iconized())15 fClosedToTray = true;16 Show(!fClosedToTray);17-//#endif18 ptaskbaricon->Show(fMinimizeToTray || fClosedToTray);19+#ifdef __WXGTK__20+ }21+#endif22 }23 24 void CMainFrame::OnMouseEvents(wxMouseEvent& event)25@@ -1444,8 +1449,18 @@26 //m_listBox->Append(_("Test 2"));27 m_listBox->SetSelection(0);28 SelectPage(0);29-#ifndef __WXMSW__30- m_checkBoxMinimizeOnClose->SetLabel(_("&Minimize on close"));31+#ifdef __WXGTK__32+ m_checkBoxStartOnSystemStartup->SetLabel(_("&Start Bitcoin on window system startup"));33+ if (!mapArgs.count("-minimizetotray"))34+ {35+ // Minimize to tray is just too buggy on Linux36+ fMinimizeToTray = false;37+ m_checkBoxMinimizeToTray->SetValue(false);38+ m_checkBoxMinimizeToTray->Enable(false);39+ m_checkBoxMinimizeOnClose->SetLabel(_("&Minimize on close"));40+ }41+#endif42+#ifdef __WXMAC_OSX__43 m_checkBoxStartOnSystemStartup->Enable(false); // not implemented yet44 #endif45 46@@ -2534,6 +2549,10 @@47 pframeMain = new CMainFrame(NULL);48 if (mapArgs.count("-min"))49 pframeMain->Iconize(true);50+#ifdef __WXGTK__51+ if (!mapArgs.count("-minimizetotray"))52+ fMinimizeToTray = false;53+#endif54 pframeMain->Show(true); // have to show first to get taskbar button to hide55 if (fMinimizeToTray && pframeMain->IsIconized())56 fClosedToTray = true;
uibase.cpp (modified)
1--- v0.3.0/uibase.cpp2+++ v0.3.1/uibase.cpp3@@ -554,7 +554,7 @@4 5 bSizer631->Add( 0, 4, 0, wxEXPAND, 5 );6 7- m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Satoshi Nakamoto.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 );8+ m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Satoshi Nakamoto.\n\nThis is experimental software.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 );9 m_staticTextMain->Wrap( -1 );10 bSizer631->Add( m_staticTextMain, 0, wxALL, 5 );11
uibase.h (modified)
1--- v0.3.0/uibase.h2+++ v0.3.1/uibase.h3@@ -227,7 +227,7 @@4 5 public:6 wxStaticText* m_staticTextVersion;7- CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 532,315 ), long style = wxDEFAULT_DIALOG_STYLE );8+ CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 532,329 ), long style = wxDEFAULT_DIALOG_STYLE );9 ~CAboutDialogBase();10 11 };
util.cpp (modified)
1--- v0.3.0/util.cpp2+++ v0.3.1/util.cpp3@@ -20,13 +20,13 @@4 5 6 // Init openssl library multithreading support7-static wxMutex** ppmutexOpenSSL;8+static boost::interprocess::interprocess_mutex** ppmutexOpenSSL;9 void locking_callback(int mode, int i, const char* file, int line)10 {11 if (mode & CRYPTO_LOCK)12- ppmutexOpenSSL[i]->Lock();13+ ppmutexOpenSSL[i]->lock();14 else15- ppmutexOpenSSL[i]->Unlock();16+ ppmutexOpenSSL[i]->unlock();17 }18 19 // Init20@@ -36,9 +36,9 @@21 CInit()22 {23 // Init openssl library multithreading support24- ppmutexOpenSSL = (wxMutex**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(wxMutex*));25+ ppmutexOpenSSL = (boost::interprocess::interprocess_mutex**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(boost::interprocess::interprocess_mutex*));26 for (int i = 0; i < CRYPTO_num_locks(); i++)27- ppmutexOpenSSL[i] = new wxMutex();28+ ppmutexOpenSSL[i] = new boost::interprocess::interprocess_mutex();29 CRYPTO_set_locking_callback(locking_callback);30 31 #ifdef __WXMSW__32@@ -152,7 +152,7 @@33 if (fileout)34 {35 //// Debug print useful for profiling36- //fprintf(fileout, " %"PRI64d" ", wxGetLocalTimeMillis().GetValue());37+ //fprintf(fileout, " %"PRI64d" ", GetTimeMillis());38 va_list arg_ptr;39 va_start(arg_ptr, pszFormat);40 ret = vfprintf(fileout, pszFormat, arg_ptr);41@@ -521,6 +521,69 @@42 43 44 45+#ifdef __WXMSW__46+typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);47+48+string MyGetSpecialFolderPath(int nFolder, bool fCreate)49+{50+ char pszPath[MAX_PATH+100] = "";51+52+ // SHGetSpecialFolderPath isn't always available on old Windows versions53+ HMODULE hShell32 = LoadLibraryA("shell32.dll");54+ if (hShell32)55+ {56+ PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =57+ (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");58+ if (pSHGetSpecialFolderPath)59+ (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);60+ FreeModule(hShell32);61+ }62+63+ // Backup option64+ if (pszPath[0] == '\0')65+ {66+ if (nFolder == CSIDL_STARTUP)67+ {68+ strcpy(pszPath, getenv("USERPROFILE"));69+ strcat(pszPath, "\\Start Menu\\Programs\\Startup");70+ }71+ else if (nFolder == CSIDL_APPDATA)72+ {73+ strcpy(pszPath, getenv("APPDATA"));74+ }75+ }76+77+ return pszPath;78+}79+#endif80+81+string GetDefaultDataDir()82+{83+ // Windows: C:\Documents and Settings\username\Application Data\Bitcoin84+ // Mac: ~/Library/Application Support/Bitcoin85+ // Unix: ~/.bitcoin86+#ifdef __WXMSW__87+ // Windows88+ return MyGetSpecialFolderPath(CSIDL_APPDATA, true) + "\\Bitcoin";89+#else90+ char* pszHome = getenv("HOME");91+ if (pszHome == NULL || strlen(pszHome) == 0)92+ pszHome = (char*)"/";93+ string strHome = pszHome;94+ if (strHome[strHome.size()-1] != '/')95+ strHome += '/';96+#ifdef __WXOSX__97+ // Mac98+ strHome += "Library/Application Support/";99+ _mkdir(strHome.c_str());100+ return strHome + "Bitcoin";101+#else102+ // Unix103+ return strHome + ".bitcoin";104+#endif105+#endif106+}107+108 void GetDataDir(char* pszDir)109 {110 // pszDir must be at least MAX_PATH length.111@@ -538,15 +601,11 @@112 {113 // This can be called during exceptions by printf, so we cache the114 // value so we don't have to do memory allocations after that.115- // wxStandardPaths::GetUserDataDir116- // Return the directory for the user-dependent application data files:117- // Unix: ~/.appname118- // Windows: C:\Documents and Settings\username\Application Data\appname119- // Mac: ~/Library/Application Support/appname120 static char pszCachedDir[MAX_PATH];121 if (pszCachedDir[0] == 0)122 {123- strlcpy(pszCachedDir, wxStandardPaths::Get().GetUserDataDir().c_str(), sizeof(pszCachedDir));124+ //strlcpy(pszCachedDir, wxStandardPaths::Get().GetUserDataDir().c_str(), sizeof(pszCachedDir));125+ strlcpy(pszCachedDir, GetDefaultDataDir().c_str(), sizeof(pszCachedDir));126 _mkdir(pszCachedDir);127 }128 strlcpy(pszDir, pszCachedDir, MAX_PATH);
util.h (modified)
1--- v0.3.0/util.h2+++ v0.3.1/util.h3@@ -141,6 +141,10 @@4 const char* wxGetTranslation(const char* psz);5 int GetFilesize(FILE* file);6 void GetDataDir(char* pszDirRet);7+#ifdef __WXMSW__8+string MyGetSpecialFolderPath(int nFolder, bool fCreate);9+#endif10+string GetDefaultDataDir();11 string GetDataDir();12 void ShrinkDebugFile();13 uint64 GetRand(uint64 nMax);14@@ -174,13 +178,13 @@15 bool TryEnter() { return TryEnterCriticalSection(&cs); }16 #else17 protected:18- wxMutex mutex;19+ boost::interprocess::interprocess_recursive_mutex mutex;20 public:21- explicit CCriticalSection() : mutex(wxMUTEX_RECURSIVE) { }22+ explicit CCriticalSection() { }23 ~CCriticalSection() { }24- void Enter() { mutex.Lock(); }25- void Leave() { mutex.Unlock(); }26- bool TryEnter() { return mutex.TryLock() == wxMUTEX_NO_ERROR; }27+ void Enter() { mutex.lock(); }28+ void Leave() { mutex.unlock(); }29+ bool TryEnter() { return mutex.try_lock(); }30 #endif31 public:32 const char* pszFile;33@@ -324,7 +328,8 @@34 35 inline int64 GetTimeMillis()36 {37- return wxGetLocalTimeMillis().GetValue();38+ return (posix_time::ptime(posix_time::microsec_clock::universal_time()) -39+ posix_time::ptime(gregorian::date(1970,1,1))).total_milliseconds();40 }41 42 inline string DateTimeStrFormat(const char* pszFormat, int64 nTime)43@@ -513,7 +518,7 @@44 return hthread;45 }46 47-#define THREAD_PRIORITY_LOWEST PRIO_MIN48+#define THREAD_PRIORITY_LOWEST PRIO_MAX49 #define THREAD_PRIORITY_BELOW_NORMAL 250 #define THREAD_PRIORITY_NORMAL 051 #define THREAD_PRIORITY_ABOVE_NORMAL 0
