| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "ui/base/resource/data_pack.h" | 5 #include "ui/base/resource/data_pack.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 255 } |
| 256 | 256 |
| 257 if (textEncodingType != UTF8 && textEncodingType != UTF16 && | 257 if (textEncodingType != UTF8 && textEncodingType != UTF16 && |
| 258 textEncodingType != BINARY) { | 258 textEncodingType != BINARY) { |
| 259 LOG(ERROR) << "Invalid text encoding type, got " << textEncodingType | 259 LOG(ERROR) << "Invalid text encoding type, got " << textEncodingType |
| 260 << ", expected between " << BINARY << " and " << UTF16; | 260 << ", expected between " << BINARY << " and " << UTF16; |
| 261 base::CloseFile(file); | 261 base::CloseFile(file); |
| 262 return false; | 262 return false; |
| 263 } | 263 } |
| 264 | 264 |
| 265 uint8 write_buffer = textEncodingType; | 265 uint8 write_buffer = static_cast<uint8>(textEncodingType); |
| 266 if (fwrite(&write_buffer, sizeof(uint8), 1, file) != 1) { | 266 if (fwrite(&write_buffer, sizeof(uint8), 1, file) != 1) { |
| 267 LOG(ERROR) << "Failed to write file text resources encoding"; | 267 LOG(ERROR) << "Failed to write file text resources encoding"; |
| 268 base::CloseFile(file); | 268 base::CloseFile(file); |
| 269 return false; | 269 return false; |
| 270 } | 270 } |
| 271 | 271 |
| 272 // Each entry is a uint16 + a uint32. We have an extra entry after the last | 272 // Each entry is a uint16 + a uint32. We have an extra entry after the last |
| 273 // item so we can compute the size of the list item. | 273 // item so we can compute the size of the list item. |
| 274 uint32 index_length = (entry_count + 1) * sizeof(DataPackEntry); | 274 uint32 index_length = (entry_count + 1) * sizeof(DataPackEntry); |
| 275 uint32 data_offset = kHeaderLength + index_length; | 275 uint32 data_offset = kHeaderLength + index_length; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 return false; | 316 return false; |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| 320 base::CloseFile(file); | 320 base::CloseFile(file); |
| 321 | 321 |
| 322 return true; | 322 return true; |
| 323 } | 323 } |
| 324 | 324 |
| 325 } // namespace ui | 325 } // namespace ui |
| OLD | NEW |