Bitcoin
filename.h
Go to the documentation of this file.
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 {
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 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);
44 
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);
50 
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);
55 
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);
59 
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);
63 
64 // Return the name of the info log file for "dbname".
65 extern std::string InfoLogFileName(const std::string& dbname);
66 
67 // Return the name of the old info log file for "dbname".
68 extern std::string OldInfoLogFileName(const std::string& dbname);
69 
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);
76 
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);
81 
82 
83 } // namespace leveldb
84 
85 #endif // STORAGE_LEVELDB_DB_FILENAME_H_
Definition: autocompact_test.cc:11
Definition: filename.h:21
filename
Definition: custom_dsstore.py:46
bool ParseFileName(const std::string &fname, uint64_t *number, FileType *type)
Definition: filename.cc:80
std::string OldInfoLogFileName(const std::string &dbname)
Definition: filename.cc:68
Definition: filename.h:24
Definition: filename.h:25
std::string TempFileName(const std::string &dbname, uint64_t number)
Definition: filename.cc:58
std::string InfoLogFileName(const std::string &dbname)
Definition: filename.cc:63
Definition: filename.h:27
Definition: filename.h:26
std::string TableFileName(const std::string &name, uint64_t number)
Definition: filename.cc:32
Definition: filename.h:22
std::string DescriptorFileName(const std::string &dbname, uint64_t number)
Definition: filename.cc:42
unsigned long long uint64_t
Definition: stdint.h:22
static char dbname[200]
Definition: c_test.c:15
Status SetCurrentFile(Env *env, const std::string &dbname, uint64_t descriptor_number)
Definition: filename.cc:126
std::string CurrentFileName(const std::string &dbname)
Definition: filename.cc:50
std::string SSTTableFileName(const std::string &name, uint64_t number)
Definition: filename.cc:37
std::string LogFileName(const std::string &name, uint64_t number)
Definition: filename.cc:27
FileType
Definition: filename.h:20
Definition: filename.h:23
std::string LockFileName(const std::string &dbname)
Definition: filename.cc:54