/Users/deen/code/yugabyte-db/src/yb/rocksdb/utilities/convenience/info_log_finder.cc
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | | // This source code is licensed under the BSD-style license found in the |
3 | | // LICENSE file in the root directory of this source tree. An additional grant |
4 | | // of patent rights can be found in the PATENTS file in the same directory. |
5 | | // |
6 | | // The following only applies to changes made to this file as part of YugaByte development. |
7 | | // |
8 | | // Portions Copyright (c) YugaByte, Inc. |
9 | | // |
10 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
11 | | // in compliance with the License. You may obtain a copy of the License at |
12 | | // |
13 | | // http://www.apache.org/licenses/LICENSE-2.0 |
14 | | // |
15 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
16 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
17 | | // or implied. See the License for the specific language governing permissions and limitations |
18 | | // under the License. |
19 | | // |
20 | | // Copyright (c) 2012 Facebook. |
21 | | // Use of this source code is governed by a BSD-style license that can be |
22 | | // found in the LICENSE file. |
23 | | |
24 | | #include "yb/rocksdb/db.h" |
25 | | #include "yb/rocksdb/db/filename.h" |
26 | | #include "yb/rocksdb/env.h" |
27 | | |
28 | | namespace rocksdb { |
29 | | |
30 | 0 | Status GetInfoLogList(DB* db, std::vector<std::string>* info_log_list) { |
31 | 0 | uint64_t number = 0; |
32 | 0 | FileType type; |
33 | 0 | std::string path; |
34 | |
|
35 | 0 | if (!db) { |
36 | 0 | return STATUS(InvalidArgument, "DB pointer is not valid"); |
37 | 0 | } |
38 | | |
39 | 0 | const Options& options = db->GetOptions(); |
40 | 0 | if (!options.db_log_dir.empty()) { |
41 | 0 | path = options.db_log_dir; |
42 | 0 | } else { |
43 | 0 | path = db->GetName(); |
44 | 0 | } |
45 | 0 | InfoLogPrefix info_log_prefix(!options.db_log_dir.empty(), db->GetName()); |
46 | 0 | auto* env = options.env; |
47 | 0 | std::vector<std::string> file_names; |
48 | 0 | Status s = env->GetChildren(path, &file_names); |
49 | |
|
50 | 0 | if (!s.ok()) { |
51 | 0 | return s; |
52 | 0 | } |
53 | | |
54 | 0 | for (auto f : file_names) { |
55 | 0 | if (ParseFileName(f, &number, info_log_prefix.prefix, &type) && |
56 | 0 | (type == kInfoLogFile)) { |
57 | 0 | info_log_list->push_back(f); |
58 | 0 | } |
59 | 0 | } |
60 | 0 | return Status::OK(); |
61 | 0 | } |
62 | | } // namespace rocksdb |