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 <cstdint> 11 #include <string> 12 13 #include "leveldb/slice.h" 14 #include "leveldb/status.h" 15 #include "port/port.h" 16 17 namespace leveldb { 18 19 class Env; 20 21 enum FileType { 22 kLogFile, 23 kDBLockFile, 24 kTableFile, 25 kDescriptorFile, 26 kCurrentFile, 27 kTempFile, 28 kInfoLogFile // Either the current one, or an old one 29 }; 30 31 // Return the name of the log file with the specified number 32 // in the db named by "dbname". The result will be prefixed with 33 // "dbname". 34 std::string LogFileName(const std::string& dbname, uint64_t number); 35 36 // Return the name of the sstable with the specified number 37 // in the db named by "dbname". The result will be prefixed with 38 // "dbname". 39 std::string TableFileName(const std::string& dbname, uint64_t number); 40 41 // Return the legacy file name for an sstable with the specified number 42 // in the db named by "dbname". The result will be prefixed with 43 // "dbname". 44 std::string SSTTableFileName(const std::string& dbname, uint64_t number); 45 46 // Return the name of the descriptor file for the db named by 47 // "dbname" and the specified incarnation number. The result will be 48 // prefixed with "dbname". 49 std::string DescriptorFileName(const std::string& dbname, 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 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 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 std::string TempFileName(const std::string& dbname, uint64_t number); 63 64 // Return the name of the info log file for "dbname". 65 std::string InfoLogFileName(const std::string& dbname); 66 67 // Return the name of the old info log file for "dbname". 68 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 bool ParseFileName(const std::string& filename, uint64_t* number, 74 FileType* type); 75 76 // Make the CURRENT file point to the descriptor file with the 77 // specified number. 78 Status SetCurrentFile(Env* env, const std::string& dbname, 79 uint64_t descriptor_number); 80 81 } // namespace leveldb 82 83 #endif // STORAGE_LEVELDB_DB_FILENAME_H_ 84