#pragma once
#include <stdint.h>
-#include <unordered_map>
+
#include <string>
+#include <unordered_map>
#include <vector>
#include "options/db_options.h"
class Env;
class Directory;
+class SystemClock;
class WritableFileWriter;
#ifdef OS_WIN
-const char kFilePathSeparator = '\\';
+constexpr char kFilePathSeparator = '\\';
#else
-const char kFilePathSeparator = '/';
+constexpr char kFilePathSeparator = '/';
#endif
// Return the name of the log file with the specified number
extern std::string BlobFileName(const std::string& dbname,
const std::string& blob_dir, uint64_t number);
-static const std::string ARCHIVAL_DIR = "archive";
-
extern std::string ArchivalDirectory(const std::string& dbname);
// Return the name of the archived log file with the specified number
// in the db named by "dbname". The result will be prefixed with "dbname".
-extern std::string ArchivedLogFileName(const std::string& dbname,
- uint64_t num);
+extern std::string ArchivedLogFileName(const std::string& dbname, uint64_t num);
extern std::string MakeTableFileName(const std::string& name, uint64_t number);
extern std::string DescriptorFileName(const std::string& dbname,
uint64_t number);
+extern std::string DescriptorFileName(uint64_t number);
+
+extern const std::string kCurrentFileName; // = "CURRENT"
+
// Return the name of the current file. This file contains the name
// of the current manifest file. The result will be prefixed with
// "dbname".
const std::string& db_path = "",
const std::string& log_dir = "");
-static const std::string kOptionsFileNamePrefix = "OPTIONS-";
-static const std::string kTempFileNameSuffix = "dbtmp";
+extern const std::string kOptionsFileNamePrefix; // = "OPTIONS-"
+extern const std::string kTempFileNameSuffix; // = "dbtmp"
// Return a options file name given the "dbname" and file number.
// Format: OPTIONS-[number].dbtmp
extern std::string OptionsFileName(const std::string& dbname,
uint64_t file_num);
+extern std::string OptionsFileName(uint64_t file_num);
// Return a temp options file name given the "dbname" and file number.
// Format: OPTIONS-[number]
// Return the name to use for a metadatabase. The result will be prefixed with
// "dbname".
-extern std::string MetaDatabaseName(const std::string& dbname,
- uint64_t number);
+extern std::string MetaDatabaseName(const std::string& dbname, uint64_t number);
// Return the name of the Identity file which stores a unique number for the db
// that will get regenerated if the db loses all its data and is recreated fresh
FileType* type, WalFileType* log_type = nullptr);
// Make the CURRENT file point to the descriptor file with the
-// specified number.
+// specified number. On its success and when dir_contains_current_file is not
+// nullptr, the function will fsync the directory containing the CURRENT file
+// when
extern IOStatus SetCurrentFile(FileSystem* fs, const std::string& dbname,
uint64_t descriptor_number,
- FSDirectory* directory_to_fsync);
+ FSDirectory* dir_contains_current_file);
// Make the IDENTITY file for the db
extern Status SetIdentityFile(Env* env, const std::string& dbname,
const std::string& db_id = {});
// Sync manifest file `file`.
-extern IOStatus SyncManifest(Env* env, const ImmutableDBOptions* db_options,
+extern IOStatus SyncManifest(const ImmutableDBOptions* db_options,
WritableFileWriter* file);
// Return list of file names of info logs in `file_names`.
// The list only contains file name. The parent directory name is stored
// in `parent_dir`.
// `db_log_dir` should be the one as in options.db_log_dir
-extern Status GetInfoLogFiles(Env* env, const std::string& db_log_dir,
+extern Status GetInfoLogFiles(const std::shared_ptr<FileSystem>& fs,
+ const std::string& db_log_dir,
const std::string& dbname,
std::string* parent_dir,
std::vector<std::string>* file_names);