Update to LevelDB 1.20
[bitcoinplatinum.git] / src / leveldb / db / filename.h
blob87a752605d14abc2a0e3b715d412bf36ce2cdd86
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
3 // found in the LICENSE file. See the AUTHORS file for names of contributors.
4 //
5 // File names used by DB code
7 #ifndef STORAGE_LEVELDB_DB_FILENAME_H_
8 #define STORAGE_LEVELDB_DB_FILENAME_H_
10 #include <stdint.h>
11 #include <string>
12 #include "leveldb/slice.h"
13 #include "leveldb/status.h"
14 #include "port/port.h"
16 namespace leveldb {
18 class Env;
20 enum FileType {
21 kLogFile,
22 kDBLockFile,
23 kTableFile,
24 kDescriptorFile,
25 kCurrentFile,
26 kTempFile,
27 kInfoLogFile // Either the current one, or an old one
30 // Return the name of the log file with the specified number
31 // in the db named by "dbname". The result will be prefixed with
32 // "dbname".
33 extern std::string LogFileName(const std::string& dbname, uint64_t number);
35 // Return the name of the sstable with the specified number
36 // in the db named by "dbname". The result will be prefixed with
37 // "dbname".
38 extern std::string TableFileName(const std::string& dbname, uint64_t number);
40 // Return the legacy file name for an sstable with the specified number
41 // in the db named by "dbname". The result will be prefixed with
42 // "dbname".
43 extern std::string SSTTableFileName(const std::string& dbname, uint64_t number);
45 // Return the name of the descriptor file for the db named by
46 // "dbname" and the specified incarnation number. The result will be
47 // prefixed with "dbname".
48 extern std::string DescriptorFileName(const std::string& dbname,
49 uint64_t number);
51 // Return the name of the current file. This file contains the name
52 // of the current manifest file. The result will be prefixed with
53 // "dbname".
54 extern std::string CurrentFileName(const std::string& dbname);
56 // Return the name of the lock file for the db named by
57 // "dbname". The result will be prefixed with "dbname".
58 extern std::string LockFileName(const std::string& dbname);
60 // Return the name of a temporary file owned by the db named "dbname".
61 // The result will be prefixed with "dbname".
62 extern std::string TempFileName(const std::string& dbname, uint64_t number);
64 // Return the name of the info log file for "dbname".
65 extern std::string InfoLogFileName(const std::string& dbname);
67 // Return the name of the old info log file for "dbname".
68 extern std::string OldInfoLogFileName(const std::string& dbname);
70 // If filename is a leveldb file, store the type of the file in *type.
71 // The number encoded in the filename is stored in *number. If the
72 // filename was successfully parsed, returns true. Else return false.
73 extern bool ParseFileName(const std::string& filename,
74 uint64_t* number,
75 FileType* type);
77 // Make the CURRENT file point to the descriptor file with the
78 // specified number.
79 extern Status SetCurrentFile(Env* env, const std::string& dbname,
80 uint64_t descriptor_number);
83 } // namespace leveldb
85 #endif // STORAGE_LEVELDB_DB_FILENAME_H_