filename.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef STORAGE_LEVELDB_DB_FILENAME_H_
  7. #define STORAGE_LEVELDB_DB_FILENAME_H_
  8. #include <stdint.h>
  9. #include <string>
  10. #include "leveldb/slice.h"
  11. #include "leveldb/status.h"
  12. #include "port/port.h"
  13. namespace leveldb {
  14. class Env;
  15. enum FileType {
  16. kLogFile,
  17. kDBLockFile,
  18. kTableFile,
  19. kDescriptorFile,
  20. kCurrentFile,
  21. kTempFile,
  22. kInfoLogFile // Either the current one, or an old one
  23. };
  24. // Return the name of the log file with the specified number
  25. // in the db named by "dbname". The result will be prefixed with
  26. // "dbname".
  27. extern std::string LogFileName(const std::string& dbname, uint64_t number);
  28. // Return the name of the sstable with the specified number
  29. // in the db named by "dbname". The result will be prefixed with
  30. // "dbname".
  31. extern std::string TableFileName(const std::string& dbname, uint64_t number);
  32. // Return the name of the descriptor file for the db named by
  33. // "dbname" and the specified incarnation number. The result will be
  34. // prefixed with "dbname".
  35. extern std::string DescriptorFileName(const std::string& dbname,
  36. uint64_t number);
  37. // Return the name of the current file. This file contains the name
  38. // of the current manifest file. The result will be prefixed with
  39. // "dbname".
  40. extern std::string CurrentFileName(const std::string& dbname);
  41. // Return the name of the lock file for the db named by
  42. // "dbname". The result will be prefixed with "dbname".
  43. extern std::string LockFileName(const std::string& dbname);
  44. // Return the name of a temporary file owned by the db named "dbname".
  45. // The result will be prefixed with "dbname".
  46. extern std::string TempFileName(const std::string& dbname, uint64_t number);
  47. // Return the name of the info log file for "dbname".
  48. extern std::string InfoLogFileName(const std::string& dbname);
  49. // Return the name of the old info log file for "dbname".
  50. extern std::string OldInfoLogFileName(const std::string& dbname);
  51. // If filename is a leveldb file, store the type of the file in *type.
  52. // The number encoded in the filename is stored in *number. If the
  53. // filename was successfully parsed, returns true. Else return false.
  54. extern bool ParseFileName(const std::string& filename,
  55. uint64_t* number,
  56. FileType* type);
  57. // Make the CURRENT file point to the descriptor file with the
  58. // specified number.
  59. extern Status SetCurrentFile(Env* env, const std::string& dbname,
  60. uint64_t descriptor_number);
  61. } // namespace leveldb
  62. #endif // STORAGE_LEVELDB_DB_FILENAME_H_