zcashd/util/env.cc

101 lines
2.2 KiB
C++
Raw Normal View History

// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include "leveldb/env.h"
namespace leveldb {
Env::~Env() {
}
Squashed 'src/leveldb/' changes from 20ca81f08..a31c8aa40 a31c8aa40 Add NewAppendableFile for win32 environment 1913d718e Merge upstream LevelDB 1.19 3080a45b6 Increase leveldb version to 1.19. fa6dc010a A zippy change broke test assumptions about the size of compressed output. Fix the tests by allowing more slop in zippy's behavior. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123432472 06a191b8d fix problems in LevelDB's caching code a7bff697b Fix LevelDB build when asserts are enabled in release builds. (#367) ea992b467 Change std::uint64_t to uint64_t (#354) e84b5bdb5 This CL fixes a bug encountered when reading records from leveldb files that have been split, as in a [] input task split. 321134390 Deleted redundant null ptr check prior to delete. 7306ef856 Merge pull request #348 from randomascii/master 6b18316d0 Fix signed/unsigned mismatch on VC++ builds adbe3eb07 Putting build artifacts in subdirectory. 2d0320a45 Merge pull request #329 from ralphtheninja/travis-badge dd1c3c357 add travis build badge 43fcf23af Merge pull request #328 from cmumford/master 9fcae6164 Added a Travis CI build file. dac40d25f Merge pull request #284 from ideawu/master 8ec241a3b Merge pull request #317 from falvojr/patch-1 5d36bedd1 Merge pull request #272 from vapier/master 4753c9b61 Added a contributors section to README.md e2446d084 Merge pull request #275 from paulirish/patch-1 706b7f8d4 Resolve race when getting approximate-memory-usage property 3c9ff3c69 Only compiling TrimSpace on linux. f8d205cf8 Including atomic_pointer.h in port_posix 889de31a5 Let LevelDB use xcrun to determine Xcode.app path instead of using a hardcoded path. 528c2bc6a Add "approximate-memory-usage" property to leveldb::DB::GetProperty 359b6bcec Add leveldb::Cache::Prune 50e77a826 Fix size_t/int comparison/conversion issues in leveldb. 5208e7952 Added leveldb::Status::IsInvalidArgument() method. ce45404bb Suppress error reporting after seeking but before a valid First or Full record is encountered. b9afa1f2e include <assert> -> <cassert> edf2939c0 Update README.md 65190ac48 Will not reuse manifest if reuse_logs options is false. ac1d69da3 LevelDB now attempts to reuse the preceding MANIFEST and log file when re-opened. 76bba139c fix indent 8fcceb2a6 log compaction output file's level along with number 0e0f07417 documentation. improved link c85addcdf readme: improved documentation link ceff6f121 Fix Android/MIPS build. 77948e7ee Add benchmark that measures cost of repeatedly opening the database. 34ad72e3e Move header guard below copyright banner. a75d435d1 Clean up layering of storage/leveldb/... b234f65b3 Added a new fault injection test. c4c38f9c1 Add arm64 support to leveldb. cea9b10e5 Fixed incorrect comment wording for Iterator::Seek. c00c569f2 Deleted old README file. git-subtree-dir: src/leveldb git-subtree-split: a31c8aa408d5594830f7cb20ead1ef1dff51b79e
2020-09-22 16:04:47 -07:00
Status Env::NewAppendableFile(const std::string& fname, WritableFile** result) {
return Status::NotSupported("NewAppendableFile", fname);
}
SequentialFile::~SequentialFile() {
}
RandomAccessFile::~RandomAccessFile() {
}
WritableFile::~WritableFile() {
}
Logger::~Logger() {
}
FileLock::~FileLock() {
}
void Log(Logger* info_log, const char* format, ...) {
if (info_log != NULL) {
va_list ap;
va_start(ap, format);
info_log->Logv(format, ap);
va_end(ap);
}
}
static Status DoWriteStringToFile(Env* env, const Slice& data,
const std::string& fname,
bool should_sync) {
WritableFile* file;
Status s = env->NewWritableFile(fname, &file);
if (!s.ok()) {
return s;
}
s = file->Append(data);
if (s.ok() && should_sync) {
s = file->Sync();
}
if (s.ok()) {
s = file->Close();
}
delete file; // Will auto-close if we did not close above
if (!s.ok()) {
env->DeleteFile(fname);
}
return s;
}
Status WriteStringToFile(Env* env, const Slice& data,
const std::string& fname) {
return DoWriteStringToFile(env, data, fname, false);
}
Status WriteStringToFileSync(Env* env, const Slice& data,
const std::string& fname) {
return DoWriteStringToFile(env, data, fname, true);
}
Status ReadFileToString(Env* env, const std::string& fname, std::string* data) {
data->clear();
SequentialFile* file;
Status s = env->NewSequentialFile(fname, &file);
if (!s.ok()) {
return s;
}
static const int kBufferSize = 8192;
char* space = new char[kBufferSize];
while (true) {
Slice fragment;
s = file->Read(kBufferSize, &fragment, space);
if (!s.ok()) {
break;
}
data->append(fragment.data(), fragment.size());
if (fragment.empty()) {
break;
}
}
delete[] space;
delete file;
return s;
}
EnvWrapper::~EnvWrapper() {
}
} // namespace leveldb