diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-01 17:40:13 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-01 17:40:13 +0000 |
commit | 836f134c56bfa714217ca12a73482205c1480774 (patch) | |
tree | 5c5b9d938a712e09831bdd32022e1b3716c5fbdf /chrome/tools | |
parent | d46d6f3b80099ce0c630185a2e86b649bba49254 (diff) | |
download | chromium_src-836f134c56bfa714217ca12a73482205c1480774.zip chromium_src-836f134c56bfa714217ca12a73482205c1480774.tar.gz chromium_src-836f134c56bfa714217ca12a73482205c1480774.tar.bz2 |
Cross-platform wrappers for fopen, _wfopen_s, etc.
Patch by Paweł Hajdan jr <phajdan.jr@gmail.com>.
http://codereview.chromium.org/6005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools')
-rw-r--r-- | chrome/tools/convert_dict/aff_reader.cc | 5 | ||||
-rw-r--r-- | chrome/tools/convert_dict/convert_dict.cc | 6 | ||||
-rw-r--r-- | chrome/tools/convert_dict/dic_reader.cc | 5 | ||||
-rw-r--r-- | chrome/tools/test/image_diff/image_diff.cc | 7 |
4 files changed, 13 insertions, 10 deletions
diff --git a/chrome/tools/convert_dict/aff_reader.cc b/chrome/tools/convert_dict/aff_reader.cc index bc04cde..06ec131 100644 --- a/chrome/tools/convert_dict/aff_reader.cc +++ b/chrome/tools/convert_dict/aff_reader.cc @@ -6,6 +6,7 @@ #include <algorithm> +#include "base/file_util.h" #include "base/string_util.h" #include "chrome/tools/convert_dict/hunspell_reader.h" @@ -44,7 +45,7 @@ void CollapseDuplicateSpaces(std::string* str) { } // namespace AffReader::AffReader(const std::string& filename) { - fopen_s(&file_, filename.c_str(), "r"); + file_ = file_util::OpenFile(filename, "r"); // Default to Latin1 in case the file doesn't specify it. encoding_ = "ISO8859-1"; @@ -52,7 +53,7 @@ AffReader::AffReader(const std::string& filename) { AffReader::~AffReader() { if (file_) - fclose(file_); + file_util::CloseFile(file_); } bool AffReader::Read() { diff --git a/chrome/tools/convert_dict/convert_dict.cc b/chrome/tools/convert_dict/convert_dict.cc index bf0a820..ab486ac 100644 --- a/chrome/tools/convert_dict/convert_dict.cc +++ b/chrome/tools/convert_dict/convert_dict.cc @@ -13,6 +13,7 @@ #include <stdio.h> +#include "base/file_util.h" #include "base/icu_util.h" #include "base/process_util.h" #include "base/string_util.h" @@ -113,14 +114,13 @@ int main(int argc, char* argv[]) { std::string out_name = file_base + ".bdic"; printf("Writing %s ...\n", out_name.c_str()); - FILE* out_file; - fopen_s(&out_file, out_name.c_str(), "wb"); + FILE* out_file = file_util::OpenFile(out_name, "wb"); if (!out_file) { printf("ERROR writing file\n"); return 1; } fwrite(&serialized[0], 1, serialized.size(), out_file); - fclose(out_file); + file_util::CloseFile(out_file); return 0; } diff --git a/chrome/tools/convert_dict/dic_reader.cc b/chrome/tools/convert_dict/dic_reader.cc index 6e549e3..8bdb8ec 100644 --- a/chrome/tools/convert_dict/dic_reader.cc +++ b/chrome/tools/convert_dict/dic_reader.cc @@ -7,6 +7,7 @@ #include <algorithm> #include <set> +#include "base/file_util.h" #include "base/string_util.h" #include "chrome/tools/convert_dict/aff_reader.h" #include "chrome/tools/convert_dict/hunspell_reader.h" @@ -45,12 +46,12 @@ void SplitDicLine(const std::string& line, std::vector<std::string>* output) { } // namespace DicReader::DicReader(const std::string& filename) { - fopen_s(&file_, filename.c_str(), "r"); + file_ = file_util::OpenFile(filename, "r"); } DicReader::~DicReader() { if (file_) - fclose(file_); + file_util::CloseFile(file_); } bool DicReader::Read(AffReader* aff_reader) { diff --git a/chrome/tools/test/image_diff/image_diff.cc b/chrome/tools/test/image_diff/image_diff.cc index 7b06ed3..65ec67a 100644 --- a/chrome/tools/test/image_diff/image_diff.cc +++ b/chrome/tools/test/image_diff/image_diff.cc @@ -13,6 +13,7 @@ #include "base/basictypes.h" #include "base/command_line.h" +#include "base/file_util.h" #include "base/gfx/png_decoder.h" #include "base/logging.h" #include "base/process_util.h" @@ -65,8 +66,8 @@ class Image { // Creates the image from the given filename on disk, and returns true on // success. bool CreateFromFilename(const char* filename) { - FILE* f; - if (fopen_s(&f, filename, "rb") != 0) + FILE* f = file_util::OpenFile(std::string(filename), "rb"); + if (!f) return false; std::vector<unsigned char> compressed; @@ -77,7 +78,7 @@ class Image { std::copy(buf, &buf[num_read], std::back_inserter(compressed)); } - fclose(f); + file_util::CloseFile(f); if (!PNGDecoder::Decode(&compressed[0], compressed.size(), PNGDecoder::FORMAT_RGBA, &data_, &w_, &h_)) { |