diff --git a/common.pri b/common.pri index f9b9928215..ced7bee255 100644 --- a/common.pri +++ b/common.pri @@ -103,7 +103,9 @@ win32-msvc* { } win32-msvc2010 { - DEFINES += _HAS_CPP0X=0 # disable tr1 and c++0x features to avoid build errors + # disable tr1 and c++0x features to avoid build errors + DEFINES += _HAS_CPP0X=0 + DEFINES += BOOST_NO_CXX11_HDR_ARRAY BOOST_NO_CXX11_HDR_TYPEINDEX BOOST_NO_CXX11_SMART_PTR QMAKE_CFLAGS_RELEASE += /GL QMAKE_CXXFLAGS_RELEASE += /GL QMAKE_LFLAGS_RELEASE += /LTCG diff --git a/map/bookmark.hpp b/map/bookmark.hpp index 4adfb8b00d..af162f7060 100644 --- a/map/bookmark.hpp +++ b/map/bookmark.hpp @@ -71,3 +71,8 @@ public: /// Non-const category is needed to "edit" bookmark (actually, re-add it) typedef pair BookmarkAndCategory; +inline BookmarkAndCategory MakeEmptyBookmarkAndCategory() +{ + return BookmarkAndCategory(reinterpret_cast(0), + reinterpret_cast(0)); +} diff --git a/map/framework.cpp b/map/framework.cpp index b056ce5f0d..1e96ab918a 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -356,7 +356,7 @@ BookmarkAndCategory Framework::GetBookmark(m2::PointD pt) const { // @TODO Refactor. Why bookmarks can't be retrieved? Change pixel point to global point. if (m_renderPolicy == 0) - return BookmarkAndCategory(0, 0); + return MakeEmptyBookmarkAndCategory(); return GetBookmark(pt, m_renderPolicy->VisualScale()); } diff --git a/platform/chunks_download_strategy.cpp b/platform/chunks_download_strategy.cpp index 9c6be13b27..de4b66e80c 100644 --- a/platform/chunks_download_strategy.cpp +++ b/platform/chunks_download_strategy.cpp @@ -32,7 +32,7 @@ ChunksDownloadStrategy::GetChunk(RangeT const & range) else { LOG(LERROR, ("Downloader error. Invalid chunk range: ", range)); - return pair(0, -1); + return pair(reinterpret_cast(0), -1); } } diff --git a/platform/platform_tests/platform_test.cpp b/platform/platform_tests/platform_test.cpp index 3f8a0e01bb..8316d566a1 100644 --- a/platform/platform_tests/platform_test.cpp +++ b/platform/platform_tests/platform_test.cpp @@ -108,3 +108,9 @@ UNIT_TEST(CpuCores) TEST_GREATER(coresNum, 0, ()); TEST_LESS_OR_EQUAL(coresNum, 128, ()); } + +UNIT_TEST(GetWritableStorageStatus) +{ + TEST_EQUAL(Platform::STORAGE_OK, GetPlatform().GetWritableStorageStatus(100000), ()); + TEST_EQUAL(Platform::NOT_ENOUGH_SPACE, GetPlatform().GetWritableStorageStatus(0xFFFFFFFFUL), ()); +} diff --git a/platform/platform_win.cpp b/platform/platform_win.cpp index 78fac476da..ac57d3ad2e 100644 --- a/platform/platform_win.cpp +++ b/platform/platform_win.cpp @@ -1,10 +1,12 @@ #include "platform.hpp" +#include "../base/scope_guard.hpp" #include "../base/logging.hpp" #include "../coding/file_writer.hpp" #include "../std/windows.hpp" +#include "../std/bind.hpp" #include @@ -119,3 +121,34 @@ void Platform::RunAsync(TFunctor const & fn, Priority p) /// @todo fn(); } + +Platform::TStorageStatus Platform::GetWritableStorageStatus(uint64_t neededSize) +{ + ULARGE_INTEGER freeSpace; + if (0 == ::GetDiskFreeSpaceExA(m_writableDir.c_str(), &freeSpace, NULL, NULL)) + { + LOG(LWARNING, ("GetDiskFreeSpaceEx failed with error", GetLastError())); + return STORAGE_DISCONNECTED; + } + + if (freeSpace.u.LowPart + (freeSpace.u.HighPart << 32) < neededSize) + return NOT_ENOUGH_SPACE; + + return STORAGE_OK; +} + +bool Platform::GetFileSizeByFullPath(string const & filePath, uint64_t & size) +{ + HANDLE hFile = CreateFileA(filePath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile != INVALID_HANDLE_VALUE) + { + MY_SCOPE_GUARD(autoClose, bind(&CloseHandle, hFile)); + LARGE_INTEGER fileSize; + if (0 != GetFileSizeEx(hFile, &fileSize)) + { + size = fileSize.QuadPart; + return true; + } + } + return false; +} diff --git a/search/search_query.cpp b/search/search_query.cpp index 479a96b243..fddfe33917 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -55,7 +55,7 @@ namespace enum LangIndexT { LANG_CURRENT = 0, LANG_INPUT, LANG_INTERNATIONAL, - LANG_ENGLISH, + LANG_EN, LANG_DEFAULT, LANG_COUNT }; @@ -1165,7 +1165,7 @@ namespace impl : m_vector(pMwm->m_cont, pMwm->GetHeader()), m_lang(lang), m_query(q), m_isCancelled(isCancelled) { - m_arrEn[0] = q.GetLanguage(LANG_ENGLISH); + m_arrEn[0] = q.GetLanguage(LANG_EN); m_arrEn[1] = q.GetLanguage(LANG_INTERNATIONAL); m_arrEn[2] = q.GetLanguage(LANG_DEFAULT); } @@ -1516,7 +1516,7 @@ bool Query::MatchForSuggestionsImpl(strings::UniString const & token, int8_t lan void Query::MatchForSuggestions(strings::UniString const & token, Results & res) { if (!MatchForSuggestionsImpl(token, GetLanguage(LANG_INPUT), res)) - MatchForSuggestionsImpl(token, GetLanguage(LANG_ENGLISH), res); + MatchForSuggestionsImpl(token, GetLanguage(LANG_EN), res); } m2::RectD const & Query::GetViewport(int viewportID/* = -1*/) const diff --git a/std/bind.hpp b/std/bind.hpp index 26c2a1aa84..5968b26bd1 100644 --- a/std/bind.hpp +++ b/std/bind.hpp @@ -1,10 +1,15 @@ #pragma once #include "common_defines.hpp" +#include "target_os.hpp" #ifdef new #undef new #endif +#ifdef OMIM_OS_WINDOWS + #define BOOST_BIND_ENABLE_STDCALL +#endif + #include using boost::bind; using boost::ref;