blob: a915cb19341daa8ab3a2e9cf2320939d388b1ec1 [file] [log] [blame]
Bob Beckbc97b7a2023-04-18 08:35:15 -06001// 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
10namespace bssl {
11
12namespace fillins {
13
14FilePath::FilePath() {}
15
16FilePath::FilePath(const std::string &path) : path_(path) {}
17
18const std::string &FilePath::value() const { return path_; }
19
20FilePath 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
30void PathService::Get(PathKey key, FilePath *out) {
Bob Beckff96a482023-06-22 14:58:21 -060031 // 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 Beckbc97b7a2023-04-18 08:35:15 -060036}
37
38} // namespace fillins
39
40} // namespace bssl