[android] Move kml files when changing storage path.

This commit is contained in:
vng 2013-03-25 19:18:35 +03:00 committed by Alex Zolotarev
parent 75dc74ae2f
commit 85fc90ca1e
6 changed files with 11 additions and 10 deletions

View file

@ -29,7 +29,7 @@ extern "C"
Platform & pl = GetPlatform();
// Get regexp like this: (\.mwm$|\.ttf$)
string const regexp = "(\\" DATA_FILE_EXTENSION "$|\\.ttf$)";
string const regexp = "(" "\\"DATA_FILE_EXTENSION"$" "|" "\\"BOOKMARKS_FILE_EXTENSION"$" "|" "\\.ttf$" ")";
Platform::FilesList files;
pl.GetFilesByRegExp(from, regexp, files);
@ -51,6 +51,9 @@ extern "C"
// Add all maps again.
g_framework->AddLocalMaps();
// Reload bookmarks again
g_framework->NativeFramework()->LoadBookmarks();
return true;
}
}

View file

@ -13,6 +13,7 @@
#define READY_FILE_EXTENSION ".ready"
#define RESUME_FILE_EXTENSION ".resume3"
#define DOWNLOADING_FILE_EXTENSION ".downloading3"
#define BOOKMARKS_FILE_EXTENSION ".kml"
#define COUNTRIES_FILE "countries.txt"

View file

@ -456,7 +456,7 @@ string BookmarkCategory::RemoveInvalidSymbols(string const & name)
string BookmarkCategory::GenerateUniqueFileName(const string & path, string name)
{
string const kmlExt(".kml");
string const kmlExt(BOOKMARKS_FILE_EXTENSION);
// check if file name already contains .kml extension
size_t const extPos = name.rfind(kmlExt);

View file

@ -11,8 +11,6 @@
#include "../std/target_os.hpp"
#include "../std/vector.hpp"
#define KML_EXTENSION ".kml"
#define KMZ_EXTENSION ".kmz"
BookmarkManager::BookmarkManager(Framework& f):m_framework(f)
{
@ -59,7 +57,7 @@ void BookmarkManager::LoadBookmarks()
string const dir = GetPlatform().WritableDir();
Platform::FilesList files;
Platform::GetFilesByExt(dir, KML_EXTENSION, files);
Platform::GetFilesByExt(dir, BOOKMARKS_FILE_EXTENSION, files);
for (size_t i = 0; i < files.size(); ++i)
{
LoadBookmark(dir+files[i]);

View file

@ -44,7 +44,6 @@
/// How many pixels around touch point are used to get bookmark or POI
#define TOUCH_PIXEL_RADIUS 20
#define KML_EXTENSION ".kml"
#define KMZ_EXTENSION ".kmz"
#define DEFAULT_BOOKMARK_TYPE "placemark-red"
@ -531,7 +530,7 @@ bool Framework::AddBookmarksFile(string const & filePath)
{
string const fileExt = GetFileExt(filePath);
string fileSavePath;
if (fileExt == KML_EXTENSION)
if (fileExt == BOOKMARKS_FILE_EXTENSION)
{
fileSavePath = GenerateValidandUniqFilePathForKLM( GetFileName(filePath) );
if (!my::CopyFileX(filePath, fileSavePath))
@ -546,7 +545,7 @@ bool Framework::AddBookmarksFile(string const & filePath)
string kmlFileName;
for (size_t i = 0; i < files.size();++i)
{
if (GetFileExt(files[i]) == KML_EXTENSION)
if (GetFileExt(files[i]) == BOOKMARKS_FILE_EXTENSION)
{
kmlFileName = files[i];
break;

View file

@ -204,7 +204,7 @@ namespace
{
string const path = GetPlatform().WritableDir();
for (size_t i = 0; i < N; ++i)
FileWriter::DeleteFileX(path + arrFiles[i] + ".kml");
FileWriter::DeleteFileX(path + arrFiles[i] + BOOKMARKS_FILE_EXTENSION);
}
Bookmark const * GetBookmark(Framework const & fm, m2::PointD const & pt)
@ -376,7 +376,7 @@ UNIT_TEST(Bookmarks_IllegalFileName)
UNIT_TEST(Bookmarks_UniqueFileName)
{
string const BASE = "SomeUniqueFileName";
string const FILENAME = BASE + ".kml";
string const FILENAME = BASE + BOOKMARKS_FILE_EXTENSION;
{
FileWriter file(FILENAME);