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 FilePath()14FilePath::FilePath() {} 15 FilePath(const std::string & path)16FilePath::FilePath(const std::string &path) : path_(path) {} 17 value() const18const std::string &FilePath::value() const { return path_; } 19 AppendASCII(const std::string & ascii_path_element) const20FilePath 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 Get(PathKey key,FilePath * out)30void PathService::Get(PathKey key, FilePath *out) { 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"); 36 } 37 38 } // namespace fillins 39 40 } // namespace bssl 41