Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(751)

Unified Diff: courgette/ensemble_apply.cc

Issue 6597038: Implementation of an STL compatible allocator for Courgette on Windows.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: courgette/ensemble_apply.cc
===================================================================
--- courgette/ensemble_apply.cc (revision 76195)
+++ courgette/ensemble_apply.cc (working copy)
@@ -364,50 +364,32 @@
Status ApplyEnsemblePatch(const FilePath::CharType* old_file_name,
const FilePath::CharType* patch_file_name,
const FilePath::CharType* new_file_name) {
- Status status;
-
// First read enough of the patch file to validate the header is well-formed.
// A few varint32 numbers should fit in 100.
FilePath patch_file_path(patch_file_name);
- const int BIG_ENOUGH_FOR_HEADER = 100;
- char buffer[BIG_ENOUGH_FOR_HEADER];
- int read_count =
- file_util::ReadFile(patch_file_path, buffer, sizeof(buffer));
- if (read_count < 0)
+ file_util::MemoryMappedFile patch_file;
+ if (!patch_file.Initialize(patch_file_path))
return C_READ_OPEN_ERROR;
// 'Dry-run' the first step of the patch process to validate format of header.
SourceStream patch_header_stream;
- patch_header_stream.Init(buffer, read_count);
+ patch_header_stream.Init(patch_file.data(), patch_file.length());
EnsemblePatchApplication patch_process;
- status = patch_process.ReadHeader(&patch_header_stream);
+ Status status = patch_process.ReadHeader(&patch_header_stream);
if (status != C_OK)
return status;
- // Header smells good so read the whole patch file for real.
- int64 patch_file_size = 0;
- if (!file_util::GetFileSize(patch_file_path, &patch_file_size))
- return C_READ_ERROR;
- std::string patch_file_buffer;
- patch_file_buffer.reserve(static_cast<size_t>(patch_file_size));
- if (!file_util::ReadFileToString(patch_file_path, &patch_file_buffer))
- return C_READ_ERROR;
-
// Read the old_file.
FilePath old_file_path(old_file_name);
- int64 old_file_size = 0;
- if (!file_util::GetFileSize(old_file_path, &old_file_size))
+ file_util::MemoryMappedFile old_file;
+ if (!old_file.Initialize(old_file_path))
return C_READ_ERROR;
- std::string old_file_buffer;
- old_file_buffer.reserve(static_cast<size_t>(old_file_size));
- if (!file_util::ReadFileToString(old_file_path, &old_file_buffer))
- return C_READ_ERROR;
// Apply patch on streams.
SourceStream old_source_stream;
SourceStream patch_source_stream;
- old_source_stream.Init(old_file_buffer);
- patch_source_stream.Init(patch_file_buffer);
+ old_source_stream.Init(old_file.data(), old_file.length());
+ patch_source_stream.Init(patch_file.data(), patch_file.length());
SinkStream new_sink_stream;
status = ApplyEnsemblePatch(&old_source_stream, &patch_source_stream,
&new_sink_stream);

Powered by Google App Engine
This is Rietveld 408576698