| 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 // This tool converts Hunspell .aff/.dic pairs to a combined binary dictionary | 5 // This tool converts Hunspell .aff/.dic pairs to a combined binary dictionary |
| 6 // format (.bdic). This format is more compact, and can be more efficiently | 6 // format (.bdic). This format is more compact, and can be more efficiently |
| 7 // read by the client application. | 7 // read by the client application. |
| 8 // | 8 // |
| 9 // We do this conversion manually before publishing dictionary files. It is not | 9 // We do this conversion manually before publishing dictionary files. It is not |
| 10 // part of any build process. | 10 // part of any build process. |
| 11 // | 11 // |
| 12 // See PrintHelp() below for usage. | 12 // See PrintHelp() below for usage. |
| 13 | 13 |
| 14 #include <stdio.h> | 14 #include <stdio.h> |
| 15 | 15 |
| 16 #include "base/file_util.h" |
| 16 #include "base/icu_util.h" | 17 #include "base/icu_util.h" |
| 17 #include "base/process_util.h" | 18 #include "base/process_util.h" |
| 18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 19 #include "chrome/third_party/hunspell/google/bdict_reader.h" | 20 #include "chrome/third_party/hunspell/google/bdict_reader.h" |
| 20 #include "chrome/third_party/hunspell/google/bdict_writer.h" | 21 #include "chrome/third_party/hunspell/google/bdict_writer.h" |
| 21 #include "chrome/tools/convert_dict/aff_reader.h" | 22 #include "chrome/tools/convert_dict/aff_reader.h" |
| 22 #include "chrome/tools/convert_dict/dic_reader.h" | 23 #include "chrome/tools/convert_dict/dic_reader.h" |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 std::string serialized = writer.GetBDict(); | 107 std::string serialized = writer.GetBDict(); |
| 107 | 108 |
| 108 printf("Verifying...\n"); | 109 printf("Verifying...\n"); |
| 109 if (!VerifyWords(dic_reader.words(), serialized)) { | 110 if (!VerifyWords(dic_reader.words(), serialized)) { |
| 110 printf("ERROR converting, the dictionary does not check out OK."); | 111 printf("ERROR converting, the dictionary does not check out OK."); |
| 111 return 1; | 112 return 1; |
| 112 } | 113 } |
| 113 | 114 |
| 114 std::string out_name = file_base + ".bdic"; | 115 std::string out_name = file_base + ".bdic"; |
| 115 printf("Writing %s ...\n", out_name.c_str()); | 116 printf("Writing %s ...\n", out_name.c_str()); |
| 116 FILE* out_file; | 117 FILE* out_file = file_util::OpenFile(out_name, "wb"); |
| 117 fopen_s(&out_file, out_name.c_str(), "wb"); | |
| 118 if (!out_file) { | 118 if (!out_file) { |
| 119 printf("ERROR writing file\n"); | 119 printf("ERROR writing file\n"); |
| 120 return 1; | 120 return 1; |
| 121 } | 121 } |
| 122 fwrite(&serialized[0], 1, serialized.size(), out_file); | 122 fwrite(&serialized[0], 1, serialized.size(), out_file); |
| 123 fclose(out_file); | 123 file_util::CloseFile(out_file); |
| 124 | 124 |
| 125 return 0; | 125 return 0; |
| 126 } | 126 } |
| 127 | 127 |
| OLD | NEW |