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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SPLIT_FILE_WRITER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_SPLIT_FILE_WRITER_H__
7
8 #include "update_engine/file_writer.h"
9
10 // SplitFileWriter is an implementation of FileWriter suited to our
11 // full autoupdate format. The first 8 bytes read are assumed to be a
12 // big-endian number describing how many of the next following bytes
13 // go to the first FileWriter. After that, the rest of the bytes all
14 // go to the second FileWriter.
15
16 namespace chromeos_update_engine {
17
18 class SplitFileWriter : public FileWriter {
19 public:
20 SplitFileWriter(FileWriter* first_file_writer, FileWriter* second_file_writer)
21 : first_file_writer_(first_file_writer),
22 first_length_(0),
23 first_path_(NULL),
24 first_flags_(0),
25 first_mode_(0),
26 second_file_writer_(second_file_writer),
27 bytes_received_(0) {}
28
29 void SetFirstOpenArgs(const char* path, int flags, mode_t mode) {
30 first_path_ = path;
31 first_flags_ = flags;
32 first_mode_ = mode;
33 }
34
35 // If both succeed, returns the return value from the second Open() call.
36 // On error, both files will be left closed.
37 virtual int Open(const char* path, int flags, mode_t mode);
38
39 virtual ssize_t Write(const void* bytes, size_t count);
40
41 virtual int Close();
42
43 private:
44 // Data for the first file writer.
45 FileWriter* const first_file_writer_;
46 off_t first_length_;
47 const char* first_path_;
48 int first_flags_;
49 mode_t first_mode_;
50
51 // The scond file writeer.
52 FileWriter* const second_file_writer_;
53
54 // Bytes written thus far
55 off_t bytes_received_;
56 char first_length_buf_[sizeof(uint64_t)];
57
58 DISALLOW_COPY_AND_ASSIGN(SplitFileWriter);
59 };
60
61 } // namespace chromeos_update_engine
62
63 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SPLIT_FILE_WRITER_H__
OLDNEW
« 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