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

Unified Diff: src/platform/update_engine/split_file_writer.h

Issue 1800009: AU: SplitWriter class for parsing our full update files. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: fixes for review Created 10 years, 8 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
« no previous file with comments | « src/platform/update_engine/mock_file_writer.h ('k') | src/platform/update_engine/split_file_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/update_engine/split_file_writer.h
diff --git a/src/platform/update_engine/split_file_writer.h b/src/platform/update_engine/split_file_writer.h
new file mode 100644
index 0000000000000000000000000000000000000000..cba816136400721a2f64efeefe7266ccffa96858
--- /dev/null
+++ b/src/platform/update_engine/split_file_writer.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SPLIT_FILE_WRITER_H__
+#define CHROMEOS_PLATFORM_UPDATE_ENGINE_SPLIT_FILE_WRITER_H__
+
+#include "update_engine/file_writer.h"
+
+// SplitFileWriter is an implementation of FileWriter suited to our
+// full autoupdate format. The first 8 bytes read are assumed to be a
+// big-endian number describing how many of the next following bytes
+// go to the first FileWriter. After that, the rest of the bytes all
+// go to the second FileWriter.
+
+namespace chromeos_update_engine {
+
+class SplitFileWriter : public FileWriter {
+ public:
+ SplitFileWriter(FileWriter* first_file_writer, FileWriter* second_file_writer)
+ : first_file_writer_(first_file_writer),
+ first_length_(0),
+ first_path_(NULL),
+ first_flags_(0),
+ first_mode_(0),
+ second_file_writer_(second_file_writer),
+ bytes_received_(0) {}
+
+ void SetFirstOpenArgs(const char* path, int flags, mode_t mode) {
+ first_path_ = path;
+ first_flags_ = flags;
+ first_mode_ = mode;
+ }
+
+ // If both succeed, returns the return value from the second Open() call.
+ // On error, both files will be left closed.
+ virtual int Open(const char* path, int flags, mode_t mode);
+
+ virtual ssize_t Write(const void* bytes, size_t count);
+
+ virtual int Close();
+
+ private:
+ // Data for the first file writer.
+ FileWriter* const first_file_writer_;
+ off_t first_length_;
+ const char* first_path_;
+ int first_flags_;
+ mode_t first_mode_;
+
+ // The scond file writeer.
+ FileWriter* const second_file_writer_;
+
+ // Bytes written thus far
+ off_t bytes_received_;
+ char first_length_buf_[sizeof(uint64_t)];
+
+ DISALLOW_COPY_AND_ASSIGN(SplitFileWriter);
+};
+
+} // namespace chromeos_update_engine
+
+#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SPLIT_FILE_WRITER_H__
« no previous file with comments | « src/platform/update_engine/mock_file_writer.h ('k') | src/platform/update_engine/split_file_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698