diff --git a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp index 6316ed03fe..a5020ba219 100644 --- a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp +++ b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp @@ -295,7 +295,7 @@ extern "C" Platform::FilesList files; // Move *.mwm files - pl.GetFilesByExt(from, "*" DATA_FILE_EXTENSION, files); + pl.GetFilesByExt(from, DATA_FILE_EXTENSION, files); for (size_t i = 0; i < files.size(); ++i) { LOG(LDEBUG, ("moving map from:", from + files[i], ", to:", to + files[i])); diff --git a/base/base.pro b/base/base.pro index f7ce1aa03f..06587971b3 100644 --- a/base/base.pro +++ b/base/base.pro @@ -79,3 +79,4 @@ HEADERS += \ strings_bundle.hpp \ string_format.hpp \ object_tracker.hpp \ + regexp.hpp diff --git a/base/base_tests/base_tests.pro b/base/base_tests/base_tests.pro index 021127f81c..0cb91f591d 100644 --- a/base/base_tests/base_tests.pro +++ b/base/base_tests/base_tests.pro @@ -35,6 +35,7 @@ SOURCES += \ containers_test.cpp \ fence_manager_test.cpp \ string_format_test.cpp \ + regexp_test.cpp HEADERS += diff --git a/platform/platform_tests/regexp_test.cpp b/base/base_tests/regexp_test.cpp similarity index 100% rename from platform/platform_tests/regexp_test.cpp rename to base/base_tests/regexp_test.cpp diff --git a/platform/regexp.hpp b/base/regexp.hpp similarity index 100% rename from platform/regexp.hpp rename to base/regexp.hpp diff --git a/generator/update_generator.cpp b/generator/update_generator.cpp index 032957e27a..e18120af01 100644 --- a/generator/update_generator.cpp +++ b/generator/update_generator.cpp @@ -82,7 +82,7 @@ namespace update bool UpdateCountries(string const & dataDir) { Platform::FilesList mwmFiles; - GetPlatform().GetFilesByExt(dataDir, "*" DATA_FILE_EXTENSION, mwmFiles); + GetPlatform().GetFilesByExt(dataDir, DATA_FILE_EXTENSION, mwmFiles); // remove some files from list char const * filesToRemove[] = { diff --git a/map/framework.cpp b/map/framework.cpp index 7da9a7a73f..0c578febbd 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -152,7 +152,7 @@ CountryStatusDisplay * Framework::GetCountryStatusDisplay() const static void GetResourcesMaps(vector & outMaps) { Platform & pl = GetPlatform(); - pl.GetFilesByExt(pl.ResourcesDir(), "*" DATA_FILE_EXTENSION, outMaps); + pl.GetFilesByExt(pl.ResourcesDir(), DATA_FILE_EXTENSION, outMaps); } Framework::Framework() @@ -350,7 +350,7 @@ void Framework::LoadBookmarks() string const dir = GetPlatform().WritableDir(); Platform::FilesList files; - Platform::GetFilesByExt(dir, "*.kml", files); + Platform::GetFilesByExt(dir, ".kml", files); for (size_t i = 0; i < files.size(); ++i) { BookmarkCategory * cat = BookmarkCategory::CreateFromKMLFile(dir + files[i]); @@ -528,7 +528,7 @@ void Framework::ClearBookmarks() void Framework::GetLocalMaps(vector & outMaps) const { Platform & pl = GetPlatform(); - pl.GetFilesByExt(pl.WritableDir(), "*" DATA_FILE_EXTENSION, outMaps); + pl.GetFilesByExt(pl.WritableDir(), DATA_FILE_EXTENSION, outMaps); } void Framework::PrepareToShutdown() @@ -1333,7 +1333,7 @@ void Framework::DeleteOldMaps() { Platform & p = GetPlatform(); vector maps; - p.GetFilesByExt(p.WritableDir(), "*" DATA_FILE_EXTENSION, maps); + p.GetFilesByExt(p.WritableDir(), DATA_FILE_EXTENSION, maps); for (vector::iterator it = maps.begin(); it != maps.end(); ++it) { feature::DataHeader header; diff --git a/platform/platform.cpp b/platform/platform.cpp index e048ea1f69..93eb691731 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -59,7 +59,7 @@ void Platform::GetFontNames(FilesList & res) const for (size_t i = 0; i < ARRAY_SIZE(arr); ++i) { LOG(LDEBUG, ("Searching for fonts in", arr[i])); - GetFilesByExt(arr[i], "*.ttf", res); + GetFilesByExt(arr[i], ".ttf", res); } sort(res.begin(), res.end()); @@ -70,23 +70,9 @@ void Platform::GetFontNames(FilesList & res) const void Platform::GetFilesByExt(string const & directory, string const & ext, FilesList & outFiles) { - // Transform extension mask to regexp (*.mwm -> \.mwm$) + // Transform extension mask to regexp (.mwm -> \.mwm$) ASSERT ( !ext.empty(), () ); + ASSERT_EQUAL ( ext[0], '.' , () ); - string regexp; - if (ext[0] == '*') - { - regexp = ext + '$'; - regexp[0] = '\\'; - } - else if (ext[0] == '.') - { - regexp = '\\' + ext + '$'; - } - else - { - regexp = "\\." + ext + '$'; - } - - GetFilesByRegExp(directory, regexp, outFiles); + GetFilesByRegExp(directory, '\\' + ext + '$', outFiles); } diff --git a/platform/platform.hpp b/platform/platform.hpp index f5a9b9649d..4d38693290 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -76,7 +76,7 @@ public: /// Retrieves files list contained in given directory /// @param directory directory path with slash at the end //@{ - /// @param ext files extension to find, like ".mwm", "*.ttf" etc + /// @param ext files extension to find, like ".mwm". static void GetFilesByExt(string const & directory, string const & ext, FilesList & outFiles); static void GetFilesByRegExp(string const & directory, string const & regexp, FilesList & outFiles); //@} diff --git a/platform/platform.pro b/platform/platform.pro index 7497a66c59..4572240ac3 100644 --- a/platform/platform.pro +++ b/platform/platform.pro @@ -68,7 +68,6 @@ HEADERS += \ servers_list.hpp \ constants.hpp \ file_name_utils.hpp \ - regexp.hpp \ SOURCES += \ preferred_languages.cpp \ diff --git a/platform/platform_android.cpp b/platform/platform_android.cpp index 2b819c8050..0bc21d7021 100644 --- a/platform/platform_android.cpp +++ b/platform/platform_android.cpp @@ -1,12 +1,12 @@ #include "platform.hpp" #include "platform_unix_impl.hpp" #include "constants.hpp" -#include "regexp.hpp" #include "../coding/zip_reader.hpp" #include "../base/logging.hpp" #include "../base/thread.hpp" +#include "../base/regexp.hpp" #include diff --git a/platform/platform_qt.cpp b/platform/platform_qt.cpp index 22ad70de62..ec9c67577d 100644 --- a/platform/platform_qt.cpp +++ b/platform/platform_qt.cpp @@ -1,9 +1,10 @@ #include "platform.hpp" #include "constants.hpp" -#include "regexp.hpp" #include "../coding/file_reader.hpp" +#include "../base/regexp.hpp" + #include "../std/target_os.hpp" #include "../std/algorithm.hpp" diff --git a/platform/platform_tests/platform_test.cpp b/platform/platform_tests/platform_test.cpp index c94950881c..da031ac5e5 100644 --- a/platform/platform_tests/platform_test.cpp +++ b/platform/platform_tests/platform_test.cpp @@ -67,14 +67,14 @@ UNIT_TEST(GetFilesInDir_Smoke) string const dir = pl.WritableDir(); - pl.GetFilesByExt(dir, "*" DATA_FILE_EXTENSION, files1); + pl.GetFilesByExt(dir, DATA_FILE_EXTENSION, files1); TEST_GREATER(files1.size(), 0, ("/data/ folder should contain some data files")); pl.GetFilesByRegExp(dir, ".*\\" DATA_FILE_EXTENSION "$", files2); TEST_EQUAL(files1, files2, ()); files1.clear(); - pl.GetFilesByExt(dir, "asdnonexistentfile.dsa", files1); + pl.GetFilesByExt(dir, ".dsa", files1); TEST_EQUAL(files1.size(), 0, ()); } diff --git a/platform/platform_tests/platform_tests.pro b/platform/platform_tests/platform_tests.pro index 821e52437a..29bee1215e 100644 --- a/platform/platform_tests/platform_tests.pro +++ b/platform/platform_tests/platform_tests.pro @@ -33,4 +33,3 @@ SOURCES += \ language_test.cpp \ downloader_test.cpp \ video_timer_test.cpp \ - regexp_test.cpp \ diff --git a/platform/platform_unix_impl.cpp b/platform/platform_unix_impl.cpp index 90132f2b9d..6f50e7eee0 100644 --- a/platform/platform_unix_impl.cpp +++ b/platform/platform_unix_impl.cpp @@ -1,8 +1,8 @@ #include "platform.hpp" #include "platform_unix_impl.hpp" -#include "regexp.hpp" #include "../base/logging.hpp" +#include "../base/regexp.hpp" #include #include diff --git a/storage/storage_tests/generate_langs.cpp b/storage/storage_tests/generate_langs.cpp index b5be1e839b..7f0875169c 100644 --- a/storage/storage_tests/generate_langs.cpp +++ b/storage/storage_tests/generate_langs.cpp @@ -148,7 +148,7 @@ UNIT_TEST(MergeLanguages) }; Platform::FilesList fList; - GetPlatform().GetFilesByExt(paths[0], "*.meta", fList); + GetPlatform().GetFilesByExt(paths[0], ".meta", fList); for (size_t i = 0; i < fList.size(); ++i) {