diff options
author | vng <viktor.govako@gmail.com> | 2012-05-08 14:11:13 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:38:06 +0300 |
commit | 8d3730c562ebc893931a784927f71d4065da54ec (patch) | |
tree | 8ceea721736f9ae7a4221680df6fb8930c458636 /generator/unpack_mwm.cpp | |
parent | d84d08fc223e025da56265e167a515500b5782ad (diff) |
Add "delete_section" to generator_tool.
Diffstat (limited to 'generator/unpack_mwm.cpp')
-rw-r--r-- | generator/unpack_mwm.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/generator/unpack_mwm.cpp b/generator/unpack_mwm.cpp index 4443e0a4fc..d112de3500 100644 --- a/generator/unpack_mwm.cpp +++ b/generator/unpack_mwm.cpp @@ -1,32 +1,38 @@ #include "unpack_mwm.hpp" + #include "../coding/file_container.hpp" #include "../coding/file_writer.hpp" +#include "../coding/read_write_utils.hpp" + #include "../base/logging.hpp" #include "../base/stl_add.hpp" + #include "../std/algorithm.hpp" #include "../std/vector.hpp" + void UnpackMwm(string const & filePath) { LOG(LINFO, ("Unpacking mwm sections...")); + FilesContainerR container(filePath); vector<string> tags; container.ForEachTag(MakeBackInsertFunctor<vector<string> >(tags)); + for (size_t i = 0; i < tags.size(); ++i) { LOG(LINFO, ("Unpacking", tags[i])); - FilesContainerR::ReaderT reader = container.GetReader(tags[i]); + + ReaderSource<FilesContainerR::ReaderT> reader(container.GetReader(tags[i])); FileWriter writer(filePath + "." + tags[i]); - uint64_t const size = reader.Size(); - uint64_t pos = 0; - while (pos < size) - { - vector<char> buffer(min(static_cast<size_t>(size - pos), static_cast<size_t>(1024 * 1024))); - reader.Read(pos, &buffer[0], buffer.size()); - writer.Write(&buffer[0], buffer.size()); - pos += buffer.size(); - } + rw::ReadAndWrite(reader, writer, 1024 * 1024); } + LOG(LINFO, ("Unpacking done.")); } + +void DeleteSection(string const & filePath, string const & tag) +{ + FilesContainerW(filePath, FileWriter::OP_WRITE_EXISTING).DeleteSection(tag); +} |