| 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 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 } | 612 } |
| 613 // TODO(jorlow): Unfortunately, the FileEnumerator swallows errors, so | 613 // TODO(jorlow): Unfortunately, the FileEnumerator swallows errors, so |
| 614 // we'll always return OK. Maybe manually check for error | 614 // we'll always return OK. Maybe manually check for error |
| 615 // conditions like the file not existing? | 615 // conditions like the file not existing? |
| 616 return Status::OK(); | 616 return Status::OK(); |
| 617 } | 617 } |
| 618 | 618 |
| 619 Status ChromiumEnv::DeleteFile(const std::string& fname) { | 619 Status ChromiumEnv::DeleteFile(const std::string& fname) { |
| 620 Status result; | 620 Status result; |
| 621 // TODO(jorlow): Should we assert this is a file? | 621 // TODO(jorlow): Should we assert this is a file? |
| 622 if (!::file_util::Delete(CreateFilePath(fname), false)) { | 622 if (!::base::Delete(CreateFilePath(fname), false)) { |
| 623 result = MakeIOError(fname, "Could not delete file.", kDeleteFile); | 623 result = MakeIOError(fname, "Could not delete file.", kDeleteFile); |
| 624 RecordErrorAt(kDeleteFile); | 624 RecordErrorAt(kDeleteFile); |
| 625 } | 625 } |
| 626 return result; | 626 return result; |
| 627 } | 627 } |
| 628 | 628 |
| 629 Status ChromiumEnv::CreateDir(const std::string& name) { | 629 Status ChromiumEnv::CreateDir(const std::string& name) { |
| 630 Status result; | 630 Status result; |
| 631 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 631 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| 632 Retrier retrier(kCreateDir, this); | 632 Retrier retrier(kCreateDir, this); |
| 633 do { | 633 do { |
| 634 if (::file_util::CreateDirectoryAndGetError(CreateFilePath(name), &error)) | 634 if (::file_util::CreateDirectoryAndGetError(CreateFilePath(name), &error)) |
| 635 return result; | 635 return result; |
| 636 } while (retrier.ShouldKeepTrying(error)); | 636 } while (retrier.ShouldKeepTrying(error)); |
| 637 result = MakeIOError(name, "Could not create directory.", kCreateDir, error); | 637 result = MakeIOError(name, "Could not create directory.", kCreateDir, error); |
| 638 RecordOSError(kCreateDir, error); | 638 RecordOSError(kCreateDir, error); |
| 639 return result; | 639 return result; |
| 640 } | 640 } |
| 641 | 641 |
| 642 Status ChromiumEnv::DeleteDir(const std::string& name) { | 642 Status ChromiumEnv::DeleteDir(const std::string& name) { |
| 643 Status result; | 643 Status result; |
| 644 // TODO(jorlow): Should we assert this is a directory? | 644 // TODO(jorlow): Should we assert this is a directory? |
| 645 if (!::file_util::Delete(CreateFilePath(name), false)) { | 645 if (!::base::Delete(CreateFilePath(name), false)) { |
| 646 result = MakeIOError(name, "Could not delete directory.", kDeleteDir); | 646 result = MakeIOError(name, "Could not delete directory.", kDeleteDir); |
| 647 RecordErrorAt(kDeleteDir); | 647 RecordErrorAt(kDeleteDir); |
| 648 } | 648 } |
| 649 return result; | 649 return result; |
| 650 } | 650 } |
| 651 | 651 |
| 652 Status ChromiumEnv::GetFileSize(const std::string& fname, uint64_t* size) { | 652 Status ChromiumEnv::GetFileSize(const std::string& fname, uint64_t* size) { |
| 653 Status s; | 653 Status s; |
| 654 int64_t signed_size; | 654 int64_t signed_size; |
| 655 if (!::file_util::GetFileSize(CreateFilePath(fname), &signed_size)) { | 655 if (!::file_util::GetFileSize(CreateFilePath(fname), &signed_size)) { |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 Env* IDBEnv() { | 959 Env* IDBEnv() { |
| 960 return leveldb_env::idb_env.Pointer(); | 960 return leveldb_env::idb_env.Pointer(); |
| 961 } | 961 } |
| 962 | 962 |
| 963 Env* Env::Default() { | 963 Env* Env::Default() { |
| 964 return leveldb_env::default_env.Pointer(); | 964 return leveldb_env::default_env.Pointer(); |
| 965 } | 965 } |
| 966 | 966 |
| 967 } // namespace leveldb | 967 } // namespace leveldb |
| 968 | 968 |
| OLD | NEW |