diff options
author | vng <viktor.govako@gmail.com> | 2012-10-31 18:14:04 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:46:29 +0300 |
commit | 93f9610292ef0baadb7afd58465112c5d7968665 (patch) | |
tree | 7d73e3586163e880e486149571193918a326e07e /platform | |
parent | 65dd7e4f2bee7f55c52c02e8d5e6e2175ae9cd4b (diff) |
Fix calling convention of Platform::GetFilesByExt.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/platform.cpp | 22 | ||||
-rw-r--r-- | platform/platform.hpp | 2 | ||||
-rw-r--r-- | platform/platform.pro | 1 | ||||
-rw-r--r-- | platform/platform_android.cpp | 2 | ||||
-rw-r--r-- | platform/platform_qt.cpp | 3 | ||||
-rw-r--r-- | platform/platform_tests/platform_test.cpp | 4 | ||||
-rw-r--r-- | platform/platform_tests/platform_tests.pro | 1 | ||||
-rw-r--r-- | platform/platform_tests/regexp_test.cpp | 22 | ||||
-rw-r--r-- | platform/platform_unix_impl.cpp | 2 | ||||
-rw-r--r-- | platform/regexp.hpp | 18 |
10 files changed, 11 insertions, 66 deletions
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 <unistd.h> 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_tests/regexp_test.cpp b/platform/platform_tests/regexp_test.cpp deleted file mode 100644 index 7e0e0dea35..0000000000 --- a/platform/platform_tests/regexp_test.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "../../testing/testing.hpp" - -#include "../regexp.hpp" - - -UNIT_TEST(RegExp_Or) -{ - regexp::RegExpT exp; - regexp::Create("\\.mwm\\.(downloading2?$|resume2?$)", exp); - - TEST(regexp::IsExist("Aruba.mwm.downloading", exp), ()); - TEST(!regexp::IsExist("Aruba.mwm.downloading1", exp), ()); - TEST(regexp::IsExist("Aruba.mwm.downloading2", exp), ()); - TEST(!regexp::IsExist("Aruba.mwm.downloading3", exp), ()); - TEST(!regexp::IsExist("Aruba.mwm.downloading.tmp", exp), ()); - - TEST(regexp::IsExist("Aruba.mwm.resume", exp), ()); - TEST(!regexp::IsExist("Aruba.mwm.resume1", exp), ()); - TEST(regexp::IsExist("Aruba.mwm.resume2", exp), ()); - TEST(!regexp::IsExist("Aruba.mwm.resume3", exp), ()); - TEST(!regexp::IsExist("Aruba.mwm.resume.tmp", exp), ()); -} 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 <dirent.h> #include <sys/stat.h> diff --git a/platform/regexp.hpp b/platform/regexp.hpp deleted file mode 100644 index 171c365684..0000000000 --- a/platform/regexp.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include <boost/xpressive/xpressive.hpp> - -namespace regexp -{ - typedef boost::xpressive::sregex RegExpT; - - inline void Create(string const & regexp, RegExpT & out) - { - out = RegExpT::compile(regexp); - } - - inline bool IsExist(string const & str, RegExpT const & regexp) - { - return boost::xpressive::regex_search(str, regexp); - } -} |