Fix calling convention of Platform::GetFilesByExt.

This commit is contained in:
vng 2012-10-31 17:14:04 +03:00 committed by Alex Zolotarev
parent 65dd7e4f2b
commit 93f9610292
16 changed files with 20 additions and 33 deletions

View file

@ -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]));

View file

@ -79,3 +79,4 @@ HEADERS += \
strings_bundle.hpp \
string_format.hpp \
object_tracker.hpp \
regexp.hpp

View file

@ -35,6 +35,7 @@ SOURCES += \
containers_test.cpp \
fence_manager_test.cpp \
string_format_test.cpp \
regexp_test.cpp
HEADERS +=

View file

@ -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[] = {

View file

@ -152,7 +152,7 @@ CountryStatusDisplay * Framework::GetCountryStatusDisplay() const
static void GetResourcesMaps(vector<string> & 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<string> & 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<string> maps;
p.GetFilesByExt(p.WritableDir(), "*" DATA_FILE_EXTENSION, maps);
p.GetFilesByExt(p.WritableDir(), DATA_FILE_EXTENSION, maps);
for (vector<string>::iterator it = maps.begin(); it != maps.end(); ++it)
{
feature::DataHeader header;

View file

@ -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);
}

View file

@ -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);
//@}

View file

@ -68,7 +68,6 @@ HEADERS += \
servers_list.hpp \
constants.hpp \
file_name_utils.hpp \
regexp.hpp \
SOURCES += \
preferred_languages.cpp \

View file

@ -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>

View file

@ -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"

View file

@ -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, ());
}

View file

@ -33,4 +33,3 @@ SOURCES += \
language_test.cpp \
downloader_test.cpp \
video_timer_test.cpp \
regexp_test.cpp \

View file

@ -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>

View file

@ -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)
{