| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 10 #include "base/string_util.h" |
| 10 #include "chrome/tools/convert_dict/hunspell_reader.h" | 11 #include "chrome/tools/convert_dict/hunspell_reader.h" |
| 11 | 12 |
| 12 namespace convert_dict { | 13 namespace convert_dict { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // Returns true if the given line begins with the given case-sensitive | 17 // Returns true if the given line begins with the given case-sensitive |
| 17 // NULL-terminated ASCII string. | 18 // NULL-terminated ASCII string. |
| 18 bool StringBeginsWith(const std::string& str, const char* with) { | 19 bool StringBeginsWith(const std::string& str, const char* with) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 37 prev_space = true; | 38 prev_space = true; |
| 38 } else { | 39 } else { |
| 39 prev_space = false; | 40 prev_space = false; |
| 40 } | 41 } |
| 41 } | 42 } |
| 42 } | 43 } |
| 43 | 44 |
| 44 } // namespace | 45 } // namespace |
| 45 | 46 |
| 46 AffReader::AffReader(const std::string& filename) { | 47 AffReader::AffReader(const std::string& filename) { |
| 47 fopen_s(&file_, filename.c_str(), "r"); | 48 file_ = file_util::OpenFile(filename, "r"); |
| 48 | 49 |
| 49 // Default to Latin1 in case the file doesn't specify it. | 50 // Default to Latin1 in case the file doesn't specify it. |
| 50 encoding_ = "ISO8859-1"; | 51 encoding_ = "ISO8859-1"; |
| 51 } | 52 } |
| 52 | 53 |
| 53 AffReader::~AffReader() { | 54 AffReader::~AffReader() { |
| 54 if (file_) | 55 if (file_) |
| 55 fclose(file_); | 56 file_util::CloseFile(file_); |
| 56 } | 57 } |
| 57 | 58 |
| 58 bool AffReader::Read() { | 59 bool AffReader::Read() { |
| 59 if (!file_) | 60 if (!file_) |
| 60 return false; | 61 return false; |
| 61 | 62 |
| 62 // TODO(brettw) handle byte order mark. | 63 // TODO(brettw) handle byte order mark. |
| 63 | 64 |
| 64 bool got_command = false; | 65 bool got_command = false; |
| 65 bool got_first_af = false; | 66 bool got_first_af = false; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 269 } |
| 269 | 270 |
| 270 void AffReader::HandleEncodedCommand(const std::string& line) { | 271 void AffReader::HandleEncodedCommand(const std::string& line) { |
| 271 std::string utf8; | 272 std::string utf8; |
| 272 if (EncodingToUTF8(line, &utf8)) | 273 if (EncodingToUTF8(line, &utf8)) |
| 273 other_commands_.push_back(utf8); | 274 other_commands_.push_back(utf8); |
| 274 } | 275 } |
| 275 | 276 |
| 276 } // namespace convert_dict | 277 } // namespace convert_dict |
| 277 | 278 |
| OLD | NEW |