diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 04:55:46 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-30 04:55:46 +0000 |
commit | f08ac7eec20738a614ceadb77f0ae27c30386611 (patch) | |
tree | 7f5e7a9616e8890deaf6e09bd72d625a7ad2bf9a /third_party | |
parent | 4d3953d6e4a9dc7bff71f761d4c31dba47d1b002 (diff) | |
download | chromium_src-f08ac7eec20738a614ceadb77f0ae27c30386611.zip chromium_src-f08ac7eec20738a614ceadb77f0ae27c30386611.tar.gz chromium_src-f08ac7eec20738a614ceadb77f0ae27c30386611.tar.bz2 |
leveldb should be able to handle non-ascii db paths
BUG=94314
TEST=manually tested with --user-data-dir=<non_latin_path> option
Review URL: http://codereview.chromium.org/8056003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/leveldatabase/env_chromium.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc index dbd2046..245e2cb 100644 --- a/third_party/leveldatabase/env_chromium.cc +++ b/third_party/leveldatabase/env_chromium.cc @@ -30,9 +30,10 @@ #include "base/win/win_util.h" #endif +namespace { + #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_ANDROID) // The following are glibc-specific -namespace { size_t fread_unlocked(void *ptr, size_t size, size_t n, FILE *file) { return fread(ptr, size, n, file); @@ -56,9 +57,19 @@ int fdatasync(int fildes) { } #endif -} #endif +// Wide-char safe fopen wrapper. +FILE* fopen_internal(const char* fname, const char* mode) { +#if defined(OS_WIN) + return _wfopen(UTF8ToUTF16(fname).c_str(), ASCIIToUTF16(mode).c_str()); +#else + return fopen(fname, mode); +#endif +} + +} // namespace + namespace leveldb { namespace { @@ -174,7 +185,7 @@ class ChromiumRandomAccessFile: public RandomAccessFile { *result = Slice(scratch, (r < 0) ? 0 : r); if (r < 0) { // An error: return a non-ok status - s = Status::IOError(filename_, "Could not preform read"); + s = Status::IOError(filename_, "Could not perform read"); } return s; } @@ -247,7 +258,7 @@ class ChromiumEnv : public Env { virtual Status NewSequentialFile(const std::string& fname, SequentialFile** result) { - FILE* f = fopen(fname.c_str(), "rb"); + FILE* f = fopen_internal(fname.c_str(), "rb"); if (f == NULL) { *result = NULL; return Status::IOError(fname, strerror(errno)); @@ -275,7 +286,7 @@ class ChromiumEnv : public Env { virtual Status NewWritableFile(const std::string& fname, WritableFile** result) { *result = NULL; - FILE* f = fopen(fname.c_str(), "wb"); + FILE* f = fopen_internal(fname.c_str(), "wb"); if (f == NULL) { return Status::IOError(fname, strerror(errno)); } else { |