Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: chrome/browser/spellchecker.cc

Issue 6005: Cross-platform equivalent of fopen, _wfopen_s etc.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <io.h> 5 #include <io.h>
6 6
7 #include "chrome/browser/spellchecker.h" 7 #include "chrome/browser/spellchecker.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 word_(WideToUTF8(word)) { 464 word_(WideToUTF8(word)) {
465 } 465 }
466 466
467 private: 467 private:
468 void Run() { 468 void Run() {
469 // Add the word with a new line. Note that, although this would mean an 469 // Add the word with a new line. Note that, although this would mean an
470 // extra line after the list of words, this is potentially harmless and 470 // extra line after the list of words, this is potentially harmless and
471 // faster, compared to verifying everytime whether to append a new line 471 // faster, compared to verifying everytime whether to append a new line
472 // or not. 472 // or not.
473 word_ += "\n"; 473 word_ += "\n";
474 const char* file_name_char = file_name_.c_str(); 474 FILE* f = file_util::OpenFile(file_name_, "a+");
475 FILE* f = fopen(file_name_char, "a+");
476 fputs(word_.c_str(), f); 475 fputs(word_.c_str(), f);
477 fclose(f); 476 file_util::CloseFile(f);
478 } 477 }
479 478
480 std::string file_name_; 479 std::string file_name_;
481 std::string word_; 480 std::string word_;
482 }; 481 };
483 482
484 void SpellChecker::AddWord(const std::wstring& word) { 483 void SpellChecker::AddWord(const std::wstring& word) {
485 // Check if the |hunspell_| has been initialized at all. 484 // Check if the |hunspell_| has been initialized at all.
486 Initialize(); 485 Initialize();
487 486
488 // Add the word to hunspell. 487 // Add the word to hunspell.
489 std::string word_to_add = WideToUTF8(word); 488 std::string word_to_add = WideToUTF8(word);
490 if (!word_to_add.empty()) 489 if (!word_to_add.empty())
491 hunspell_->put_word(word_to_add.c_str()); 490 hunspell_->put_word(word_to_add.c_str());
492 491
493 // Now add the word to the custom dictionary file in the file loop. 492 // Now add the word to the custom dictionary file in the file loop.
494 if (file_loop_) { 493 if (file_loop_) {
495 file_loop_->PostTask(FROM_HERE, new AddWordToCustomDictionaryTask( 494 file_loop_->PostTask(FROM_HERE, new AddWordToCustomDictionaryTask(
496 custom_dictionary_file_name_, word)); 495 custom_dictionary_file_name_, word));
497 } else { // just run it in this thread. 496 } else { // just run it in this thread.
498 Task* write_word_task = new AddWordToCustomDictionaryTask( 497 Task* write_word_task = new AddWordToCustomDictionaryTask(
499 custom_dictionary_file_name_, word); 498 custom_dictionary_file_name_, word);
500 write_word_task->Run(); 499 write_word_task->Run();
501 } 500 }
502 } 501 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698