]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
2 | // This source code is licensed under both the GPLv2 (found in the |
3 | // COPYING file in the root directory) and Apache 2.0 License | |
4 | // (found in the LICENSE.Apache file in the root directory). | |
7c673cae FG |
5 | // |
6 | // Copyright (c) 2012 Facebook. | |
7 | // Use of this source code is governed by a BSD-style license that can be | |
8 | // found in the LICENSE file. | |
9 | ||
10 | #include "rocksdb/utilities/info_log_finder.h" | |
11 | #include "rocksdb/env.h" | |
12 | #include "util/filename.h" | |
13 | ||
14 | namespace rocksdb { | |
15 | ||
16 | Status GetInfoLogList(DB* db, std::vector<std::string>* info_log_list) { | |
17 | uint64_t number = 0; | |
18 | FileType type; | |
19 | std::string path; | |
20 | ||
21 | if (!db) { | |
22 | return Status::InvalidArgument("DB pointer is not valid"); | |
23 | } | |
24 | ||
25 | const Options& options = db->GetOptions(); | |
26 | if (!options.db_log_dir.empty()) { | |
27 | path = options.db_log_dir; | |
28 | } else { | |
29 | path = db->GetName(); | |
30 | } | |
31 | InfoLogPrefix info_log_prefix(!options.db_log_dir.empty(), db->GetName()); | |
32 | auto* env = options.env; | |
33 | std::vector<std::string> file_names; | |
34 | Status s = env->GetChildren(path, &file_names); | |
35 | ||
36 | if (!s.ok()) { | |
37 | return s; | |
38 | } | |
39 | ||
40 | for (auto f : file_names) { | |
41 | if (ParseFileName(f, &number, info_log_prefix.prefix, &type) && | |
42 | (type == kInfoLogFile)) { | |
43 | info_log_list->push_back(f); | |
44 | } | |
45 | } | |
46 | return Status::OK(); | |
47 | } | |
48 | } // namespace rocksdb |