OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 if (bytes_read != bytes_to_read) { | 55 if (bytes_read != bytes_to_read) { |
56 return -1; | 56 return -1; |
57 } | 57 } |
58 | 58 |
59 header_bytes_read_ += bytes_to_read; | 59 header_bytes_read_ += bytes_to_read; |
60 bytes_to_consume -= bytes_to_read; | 60 bytes_to_consume -= bytes_to_read; |
61 | 61 |
62 if (header_bytes_read_ == TAR_HEADER_SIZE) { | 62 if (header_bytes_read_ == TAR_HEADER_SIZE) { |
63 const char *filename = (const char *)header_; | 63 const char *filename = (const char *)header_; |
64 | 64 |
65 // The tar format stupidly represents size_teger values as | 65 // The tar format stupidly represents size_t integer values as |
66 // octal strings!! | 66 // octal strings!! |
67 size_t file_size = 0; | 67 unsigned int file_size = 0u; |
68 sscanf(header_ + 124, "%o", &file_size); | 68 sscanf(header_ + 124, "%o", &file_size); |
69 | 69 |
70 // Only callback client if this is a "real" header | 70 // Only callback client if this is a "real" header |
71 // (filename is not NULL) | 71 // (filename is not NULL) |
72 // Extra zero-padding can be added by the gzip compression | 72 // Extra zero-padding can be added by the gzip compression |
73 // (at end of archive), so ignore these ones. | 73 // (at end of archive), so ignore these ones. |
74 // | 74 // |
75 // Also, ignore entries for directories (which have zero size) | 75 // Also, ignore entries for directories (which have zero size) |
76 if (header_[0] != 0 && file_size > 0) { | 76 if (header_[0] != 0 && file_size > 0) { |
77 ArchiveFileInfo info(filename, file_size); | 77 ArchiveFileInfo info(filename, file_size); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // setting to 0 makes us want more header bytes | 135 // setting to 0 makes us want more header bytes |
136 header_bytes_read_ = 0; | 136 header_bytes_read_ = 0; |
137 } | 137 } |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 return 0; | 141 return 0; |
142 } | 142 } |
143 | 143 |
144 } // namespace o3d | 144 } // namespace o3d |
OLD | NEW |