| 587 | } |
| 588 | |
| 589 | boost::filesystem::path GetDefaultDataDir() { |
| 590 | namespace fs = boost::filesystem; |
| 591 | // Windows < Vista: C:\Documents and Settings\Username\Application Data\Coin |
| 592 | // Windows >= Vista: C:\Users\Username\AppData\Roaming\Coin |
| 593 | // Mac: ~/Library/Application Support/Coin |
| 594 | // Unix: ~/.Coin |
| 595 | #ifdef WIN32 |
| 596 | // Windows |
| 597 | return GetSpecialFolderPath(CSIDL_APPDATA) / IniCfg().GetCoinName(); |
| 598 | #else |
| 599 | fs::path pathRet; |
| 600 | char* pszHome = getenv("HOME"); |
| 601 | if (pszHome == NULL || strlen(pszHome) == 0) |
| 602 | pathRet = fs::path("/"); |
| 603 | else |
| 604 | pathRet = fs::path(pszHome); |
| 605 | #ifdef MAC_OSX |
| 606 | // Mac |
| 607 | pathRet /= "Library/Application Support"; |
| 608 | TryCreateDirectory(pathRet); |
| 609 | return pathRet / IniCfg().GetCoinName(); |
| 610 | #else |
| 611 | // Unix |
| 612 | return pathRet / ("." + IniCfg().GetCoinName()); |
| 613 | #endif |
| 614 | #endif |
| 615 | } |
| 616 | |
| 617 | static boost::filesystem::path pathCached[NULL_NETWORK_TYPE + 1]; |
| 618 | static CCriticalSection csPathCached; |