OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/tools/convert_dict/aff_reader.h" | 5 #include "chrome/tools/convert_dict/aff_reader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 vprintf(fmt, ap); | 53 vprintf(fmt, ap); |
54 va_end(ap); | 54 va_end(ap); |
55 printf("\n"); | 55 printf("\n"); |
56 exit(1); | 56 exit(1); |
57 } | 57 } |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 AffReader::AffReader(const base::FilePath& path) | 61 AffReader::AffReader(const base::FilePath& path) |
62 : has_indexed_affixes_(false) { | 62 : has_indexed_affixes_(false) { |
63 file_ = file_util::OpenFile(path, "r"); | 63 file_ = base::OpenFile(path, "r"); |
64 | 64 |
65 // Default to Latin1 in case the file doesn't specify it. | 65 // Default to Latin1 in case the file doesn't specify it. |
66 encoding_ = "ISO8859-1"; | 66 encoding_ = "ISO8859-1"; |
67 } | 67 } |
68 | 68 |
69 AffReader::~AffReader() { | 69 AffReader::~AffReader() { |
70 if (file_) | 70 if (file_) |
71 file_util::CloseFile(file_); | 71 base::CloseFile(file_); |
72 } | 72 } |
73 | 73 |
74 bool AffReader::Read() { | 74 bool AffReader::Read() { |
75 if (!file_) | 75 if (!file_) |
76 return false; | 76 return false; |
77 | 77 |
78 // TODO(brettw) handle byte order mark. | 78 // TODO(brettw) handle byte order mark. |
79 | 79 |
80 bool got_command = false; | 80 bool got_command = false; |
81 bool got_first_af = false; | 81 bool got_first_af = false; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 327 } |
328 | 328 |
329 void AffReader::HandleEncodedCommand(const std::string& line) { | 329 void AffReader::HandleEncodedCommand(const std::string& line) { |
330 std::string utf8; | 330 std::string utf8; |
331 if (!EncodingToUTF8(line, &utf8)) | 331 if (!EncodingToUTF8(line, &utf8)) |
332 Panic("Cannot encode command '%s' to utf8.", line.c_str()); | 332 Panic("Cannot encode command '%s' to utf8.", line.c_str()); |
333 other_commands_.push_back(utf8); | 333 other_commands_.push_back(utf8); |
334 } | 334 } |
335 | 335 |
336 } // namespace convert_dict | 336 } // namespace convert_dict |
OLD | NEW |