| OLD | NEW |
| 1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved. | 1 // Copyright (c) 2011 The LevelDB 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. See the AUTHORS file for names of contributors. | 3 // found in the LICENSE file. See the AUTHORS file for names of contributors. |
| 4 | 4 |
| 5 #include <errno.h> | 5 #include <errno.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <deque> | 9 #include <deque> |
| 10 | 10 |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 } | 834 } |
| 835 if (make_backup_ && fname_filepath.MatchesExtension(table_extension)) { | 835 if (make_backup_ && fname_filepath.MatchesExtension(table_extension)) { |
| 836 base::DeleteFile(fname_filepath.ReplaceExtension(backup_table_extension), | 836 base::DeleteFile(fname_filepath.ReplaceExtension(backup_table_extension), |
| 837 false); | 837 false); |
| 838 } | 838 } |
| 839 return result; | 839 return result; |
| 840 } | 840 } |
| 841 | 841 |
| 842 Status ChromiumEnv::CreateDir(const std::string& name) { | 842 Status ChromiumEnv::CreateDir(const std::string& name) { |
| 843 Status result; | 843 Status result; |
| 844 // TODO(rvargas): convert this code to base::File::Error. |
| 844 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 845 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| 845 Retrier retrier(kCreateDir, this); | 846 Retrier retrier(kCreateDir, this); |
| 846 do { | 847 do { |
| 847 if (base::CreateDirectoryAndGetError(CreateFilePath(name), &error)) | 848 if (base::CreateDirectoryAndGetError( |
| 849 CreateFilePath(name), |
| 850 reinterpret_cast<base::File::Error*>(&error))) { |
| 848 return result; | 851 return result; |
| 852 } |
| 849 } while (retrier.ShouldKeepTrying(error)); | 853 } while (retrier.ShouldKeepTrying(error)); |
| 850 result = MakeIOError(name, "Could not create directory.", kCreateDir, error); | 854 result = MakeIOError(name, "Could not create directory.", kCreateDir, error); |
| 851 RecordOSError(kCreateDir, error); | 855 RecordOSError(kCreateDir, error); |
| 852 return result; | 856 return result; |
| 853 } | 857 } |
| 854 | 858 |
| 855 Status ChromiumEnv::DeleteDir(const std::string& name) { | 859 Status ChromiumEnv::DeleteDir(const std::string& name) { |
| 856 Status result; | 860 Status result; |
| 857 // TODO(jorlow): Should we assert this is a directory? | 861 // TODO(jorlow): Should we assert this is a directory? |
| 858 if (!::base::DeleteFile(CreateFilePath(name), false)) { | 862 if (!::base::DeleteFile(CreateFilePath(name), false)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 876 } | 880 } |
| 877 | 881 |
| 878 Status ChromiumEnv::RenameFile(const std::string& src, const std::string& dst) { | 882 Status ChromiumEnv::RenameFile(const std::string& src, const std::string& dst) { |
| 879 Status result; | 883 Status result; |
| 880 base::FilePath src_file_path = CreateFilePath(src); | 884 base::FilePath src_file_path = CreateFilePath(src); |
| 881 if (!::base::PathExists(src_file_path)) | 885 if (!::base::PathExists(src_file_path)) |
| 882 return result; | 886 return result; |
| 883 base::FilePath destination = CreateFilePath(dst); | 887 base::FilePath destination = CreateFilePath(dst); |
| 884 | 888 |
| 885 Retrier retrier(kRenameFile, this); | 889 Retrier retrier(kRenameFile, this); |
| 890 // TODO(rvargas): convert this code to base::File::Error. |
| 886 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 891 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| 887 do { | 892 do { |
| 888 if (base::ReplaceFile(src_file_path, destination, &error)) | 893 if (base::ReplaceFile(src_file_path, destination, |
| 894 reinterpret_cast<base::File::Error*>(&error))) { |
| 889 return result; | 895 return result; |
| 896 } |
| 890 } while (retrier.ShouldKeepTrying(error)); | 897 } while (retrier.ShouldKeepTrying(error)); |
| 891 | 898 |
| 892 DCHECK(error != base::PLATFORM_FILE_OK); | 899 DCHECK(error != base::PLATFORM_FILE_OK); |
| 893 RecordOSError(kRenameFile, error); | 900 RecordOSError(kRenameFile, error); |
| 894 char buf[100]; | 901 char buf[100]; |
| 895 snprintf(buf, | 902 snprintf(buf, |
| 896 sizeof(buf), | 903 sizeof(buf), |
| 897 "Could not rename file: %s", | 904 "Could not rename file: %s", |
| 898 PlatformFileErrorString(error)); | 905 PlatformFileErrorString(error)); |
| 899 return MakeIOError(src, buf, kRenameFile, error); | 906 return MakeIOError(src, buf, kRenameFile, error); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 Env* IDBEnv() { | 1216 Env* IDBEnv() { |
| 1210 return leveldb_env::idb_env.Pointer(); | 1217 return leveldb_env::idb_env.Pointer(); |
| 1211 } | 1218 } |
| 1212 | 1219 |
| 1213 Env* Env::Default() { | 1220 Env* Env::Default() { |
| 1214 return leveldb_env::default_env.Pointer(); | 1221 return leveldb_env::default_env.Pointer(); |
| 1215 } | 1222 } |
| 1216 | 1223 |
| 1217 } // namespace leveldb | 1224 } // namespace leveldb |
| 1218 | 1225 |
| OLD | NEW |