MSVC
[novacoin.git] / src / leveldb / db / filename.h
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
6
7 #ifndef STORAGE_LEVELDB_DB_FILENAME_H_
8 #define STORAGE_LEVELDB_DB_FILENAME_H_
9
10 #include <stdint.h>
11 #include <string>
12 #include "leveldb/slice.h"
13 #include "leveldb/status.h"
14 #include "port/port.h"
15
16 namespace leveldb {
17
18 class Env;
19
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
28 };
29
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);
34
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);
39
40 // Return the name of the descriptor file for the db named by
41 // "dbname" and the specified incarnation number.  The result will be
42 // prefixed with "dbname".
43 extern std::string DescriptorFileName(const std::string& dbname,
44                                       uint64_t number);
45
46 // Return the name of the current file.  This file contains the name
47 // of the current manifest file.  The result will be prefixed with
48 // "dbname".
49 extern std::string CurrentFileName(const std::string& dbname);
50
51 // Return the name of the lock file for the db named by
52 // "dbname".  The result will be prefixed with "dbname".
53 extern std::string LockFileName(const std::string& dbname);
54
55 // Return the name of a temporary file owned by the db named "dbname".
56 // The result will be prefixed with "dbname".
57 extern std::string TempFileName(const std::string& dbname, uint64_t number);
58
59 // Return the name of the info log file for "dbname".
60 extern std::string InfoLogFileName(const std::string& dbname);
61
62 // Return the name of the old info log file for "dbname".
63 extern std::string OldInfoLogFileName(const std::string& dbname);
64
65 // If filename is a leveldb file, store the type of the file in *type.
66 // The number encoded in the filename is stored in *number.  If the
67 // filename was successfully parsed, returns true.  Else return false.
68 extern bool ParseFileName(const std::string& filename,
69                           uint64_t* number,
70                           FileType* type);
71
72 // Make the CURRENT file point to the descriptor file with the
73 // specified number.
74 extern Status SetCurrentFile(Env* env, const std::string& dbname,
75                              uint64_t descriptor_number);
76
77
78 }  // namespace leveldb
79
80 #endif  // STORAGE_LEVELDB_DB_FILENAME_H_