github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/c-deps/libroach/utils.h (about)

     1  // Copyright 2017 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  #pragma once
    12  
    13  #include <rocksdb/env.h>
    14  #include <rocksdb/status.h>
    15  #include <string>
    16  
    17  // Write 'contents' to a temporary file, sync, rename to 'filename'.
    18  // On non-OK status, either the original or new file will be readable,
    19  // and not some intermediate corrupted state.
    20  rocksdb::Status SafeWriteStringToFile(rocksdb::Env* env, rocksdb::Directory* dir,
    21                                        const std::string& filename, const std::string& contents);
    22  
    23  // PathAppend takes two path components and returns the new path
    24  // with a separator if not already present.
    25  std::string PathAppend(const std::string& path1, const std::string& path2);