[Cleanup] Old code with cells data files.

This commit is contained in:
vng 2011-08-29 14:31:30 +03:00 committed by Alex Zolotarev
parent b409579c6f
commit 7650a6bd86
2 changed files with 9 additions and 40 deletions

View file

@ -1,9 +1,5 @@
#include "update_generator.hpp"
#include "../coding/file_writer.hpp"
#include "../geometry/cellid.hpp"
#include "../platform/platform.hpp"
#include "../storage/country.hpp"
@ -13,10 +9,9 @@
#include "../base/logging.hpp"
#include "../base/macros.hpp"
#include "../std/target_os.hpp"
#include "../std/fstream.hpp"
#include "../std/iterator.hpp"
using namespace storage;
/// files which can be updated through downloader
@ -54,11 +49,13 @@ namespace update
platform.GetFilesInDir(dataDir, gExtensionsToUpdate[i], otherFiles);
std::copy(otherFiles.begin(), otherFiles.end(), std::back_inserter(files));
}
{ // remove minsk-pass from list
Platform::FilesList::iterator minskPassIt = std::find(files.begin(), files.end(), "minsk-pass" DATA_FILE_EXTENSION);
if (minskPassIt != files.end())
files.erase(minskPassIt);
}
if (files.empty())
{
LOG(LERROR, ("Can't find any files at path", dataDir));
@ -69,48 +66,21 @@ namespace update
LOG_SHORT(LINFO, ("Files count included in update file:", files.size()));
}
TDataFiles cellFiles;
TCommonFiles commonFiles;
string name, ext;
int32_t level = -1;
uint16_t bits;
TDataFiles dataFiles;
for (Platform::FilesList::iterator it = files.begin(); it != files.end(); ++it)
{
uint64_t size = 0;
CHECK( platform.GetFileSize(dataDir + *it, size), ());
CHECK_EQUAL( size, static_cast<uint32_t>(size), ("We don't support files > 4gb", *it));
if (SplitExtension(*it, name, ext))
{
// is it data cell file?
if (ext == DATA_FILE_EXTENSION)
{
if (CountryCellId::IsCellId(name))
{
CountryCellId cellId = CountryCellId::FromString(name);
pair<int64_t, int> bl = cellId.ToBitsAndLevel();
if (level < 0)
level = bl.second;
CHECK_EQUAL( level, bl.second, ("Data files with different level?", *it) );
bits = static_cast<uint16_t>(bl.first);
CHECK_EQUAL( name, CountryCellId::FromBitsAndLevel(bits, level).ToString(), (name));
cellFiles.push_back(make_pair(bits, static_cast<uint32_t>(size)));
}
else
{
commonFiles.push_back(make_pair(*it, static_cast<uint32_t>(size)));
}
}
else
{
commonFiles.push_back(make_pair(*it, static_cast<uint32_t>(size)));
}
}
commonFiles.push_back(make_pair(*it, static_cast<uint32_t>(size)));
}
SaveTiles(dataDir + DATA_UPDATE_FILE, level, cellFiles, commonFiles);
SaveTiles(dataDir + DATA_UPDATE_FILE, -1, dataFiles, commonFiles);
LOG_SHORT(LINFO, ("Created update file with", cellFiles.size(), "cell data files and",
commonFiles.size(), "other files"));
LOG_SHORT(LINFO, ("Created update file with ", commonFiles.size(), " files"));
return true;
}

View file

@ -16,7 +16,6 @@
#include "../base/string_utils.hpp"
#include "../base/timer.hpp"
#include "../std/fstream.hpp"
namespace storage
{