Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 1 | // Copyright 2023 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "path_service.h" |
| 6 | |
| 7 | #include <stdlib.h> |
| 8 | #include <iostream> |
| 9 | |
| 10 | namespace bssl { |
| 11 | |
| 12 | namespace fillins { |
| 13 | |
| 14 | FilePath::FilePath() {} |
| 15 | |
| 16 | FilePath::FilePath(const std::string &path) : path_(path) {} |
| 17 | |
| 18 | const std::string &FilePath::value() const { return path_; } |
| 19 | |
| 20 | FilePath FilePath::AppendASCII(const std::string &ascii_path_element) const { |
| 21 | // Append a path element to a path. Use the \ separator if this appears to |
| 22 | // be a Windows path, otherwise the Unix one. |
| 23 | if (path_.find(":\\") != std::string::npos) { |
| 24 | return FilePath(path_ + "\\" + ascii_path_element); |
| 25 | } |
| 26 | return FilePath(path_ + "/" + ascii_path_element); |
| 27 | } |
| 28 | |
| 29 | // static |
| 30 | void PathService::Get(PathKey key, FilePath *out) { |
Bob Beck | ff96a48 | 2023-06-22 14:58:21 -0600 | [diff] [blame] | 31 | // We expect our test data to live in "pki" underneath a |
| 32 | // test root directory, or in the current directry. |
| 33 | char *root_from_env = getenv("BORINGSSL_TEST_DATA_ROOT"); |
| 34 | std::string root = root_from_env ? root_from_env : "."; |
| 35 | *out = FilePath(root + "/pki"); |
Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | } // namespace fillins |
| 39 | |
| 40 | } // namespace bssl |