OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "update_engine/decompressing_file_writer.h" | 5 #include "update_engine/decompressing_file_writer.h" |
6 | 6 |
7 namespace chromeos_update_engine { | 7 namespace chromeos_update_engine { |
8 | 8 |
9 // typedef struct z_stream_s { | 9 // typedef struct z_stream_s { |
10 // Bytef *next_in; /* next input byte */ | 10 // Bytef *next_in; /* next input byte */ |
11 // uInt avail_in; /* number of bytes available at next_in */ | 11 // uInt avail_in; /* number of bytes available at next_in */ |
12 // uLong total_in; /* total nb of input bytes read so far */ | 12 // uLong total_in; /* total nb of input bytes read so far */ |
13 // | 13 // |
14 // Bytef *next_out; /* next output byte should be put there */ | 14 // Bytef *next_out; /* next output byte should be put there */ |
15 // uInt avail_out; /* remaining free space at next_out */ | 15 // uInt avail_out; /* remaining free space at next_out */ |
16 // uLong total_out; /* total nb of bytes output so far */ | 16 // uLong total_out; /* total nb of bytes output so far */ |
17 // | 17 // |
18 // char *msg; /* last error message, NULL if no error */ | 18 // char *msg; /* last error message, NULL if no error */ |
19 // struct internal_state FAR *state; /* not visible by applications */ | 19 // struct internal_state FAR *state; /* not visible by applications */ |
20 // | 20 // |
21 // alloc_func zalloc; /* used to allocate the internal state */ | 21 // alloc_func zalloc; /* used to allocate the internal state */ |
22 // free_func zfree; /* used to free the internal state */ | 22 // free_func zfree; /* used to free the internal state */ |
23 // voidpf opaque; /* private data object passed to zalloc and zfree */ | 23 // voidpf opaque; /* private data object passed to zalloc and zfree */ |
24 // | 24 // |
25 // int data_type; /* best guess about the data type: binary or text */ | 25 // int data_type; /* best guess about the data type: binary or text */ |
26 // uLong adler; /* adler32 value of the uncompressed data */ | 26 // uLong adler; /* adler32 value of the uncompressed data */ |
27 // uLong reserved; /* reserved for future use */ | 27 // uLong reserved; /* reserved for future use */ |
28 // } z_stream; | 28 // } z_stream; |
29 | 29 |
30 int GzipDecompressingFileWriter::Write(const void* bytes, size_t count) { | 30 ssize_t GzipDecompressingFileWriter::Write(const void* bytes, size_t count) { |
31 // Steps: | 31 // Steps: |
32 // put the data on next_in | 32 // put the data on next_in |
33 // call inflate until it returns nothing, each time writing what we get | 33 // call inflate until it returns nothing, each time writing what we get |
34 // check that next_in has no data left. | 34 // check that next_in has no data left. |
35 | 35 |
36 // It seems that zlib can keep internal buffers in the stream object, | 36 // It seems that zlib can keep internal buffers in the stream object, |
37 // so not all data we get fed to us this time will necessarily | 37 // so not all data we get fed to us this time will necessarily |
38 // be written out this time (in decompressed form). | 38 // be written out this time (in decompressed form). |
39 | 39 |
40 if (stream_.avail_in) { | 40 if (stream_.avail_in) { |
(...skipping 30 matching lines...) Expand all Loading... |
71 // Inflate returned no data; we're done for now. Make sure no | 71 // Inflate returned no data; we're done for now. Make sure no |
72 // input data remain. | 72 // input data remain. |
73 CHECK_EQ(0, stream_.avail_in); | 73 CHECK_EQ(0, stream_.avail_in); |
74 break; | 74 break; |
75 } | 75 } |
76 } | 76 } |
77 return count; | 77 return count; |
78 } | 78 } |
79 | 79 |
80 } // namespace chromeos_update_engine | 80 } // namespace chromeos_update_engine |
OLD | NEW |