read_write_util.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. //
  6. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  7. // Use of this source code is governed by a BSD-style license that can be
  8. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  9. #pragma once
  10. #include <atomic>
  11. #include "file/sequence_file_reader.h"
  12. #include "rocksdb/env.h"
  13. #include "rocksdb/file_system.h"
  14. namespace ROCKSDB_NAMESPACE {
  15. // Returns a WritableFile.
  16. //
  17. // env : the Env.
  18. // fname : the file name.
  19. // result : output arg. A WritableFile based on `fname` returned.
  20. // options : the Env Options.
  21. extern IOStatus NewWritableFile(FileSystem* fs, const std::string& fname,
  22. std::unique_ptr<FSWritableFile>* result,
  23. const FileOptions& options);
  24. // Read a single line from a file.
  25. bool ReadOneLine(std::istringstream* iss, SequentialFileReader* seq_file_reader,
  26. std::string* output, bool* has_data, Status* result);
  27. #ifndef NDEBUG
  28. bool IsFileSectorAligned(const size_t off, size_t sector_size);
  29. #endif // NDEBUG
  30. } // namespace ROCKSDB_NAMESPACE