Set linux credential store path.

PiperOrigin-RevId: 791932855
This commit is contained in:
Francis Tsui
2025-08-06 18:51:07 -07:00
committed by Copybara-Service
parent ae015665cd
commit 807bf7172f
3 changed files with 49 additions and 9 deletions
+11
View File
@@ -15,6 +15,16 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library")
# limitations under the License.
licenses(["notice"])
cc_library(
name = "linux_path_util",
hdrs = ["linux_path_util.h"],
visibility = ["//visibility:public"],
deps = [
"//internal/base:file_path",
"//internal/base:files",
],
)
cc_library(
name = "types",
testonly = True,
@@ -37,6 +47,7 @@ cc_library(
],
visibility = ["//visibility:private"],
deps = [
":linux_path_util",
":preferences_repository",
"//internal/base:file_path",
"//internal/base:files",
@@ -15,7 +15,6 @@
#ifndef PLATFORM_IMPL_G3_DEVICE_INFO_H_
#define PLATFORM_IMPL_G3_DEVICE_INFO_H_
#include <cstdlib>
#include <functional>
#include <optional>
#include <string>
@@ -26,6 +25,7 @@
#include "internal/base/file_path.h"
#include "internal/base/files.h"
#include "internal/platform/implementation/device_info.h"
#include "internal/platform/implementation/g3/linux_path_util.h"
namespace nearby {
namespace g3 {
@@ -49,14 +49,7 @@ class DeviceInfo : public api::DeviceInfo {
}
std::optional<FilePath> GetLocalAppDataPath() const override {
const char* home_dir = getenv("HOME");
if (home_dir == nullptr) {
return Files::GetTemporaryDirectory();
}
// Yhis matches the .NET LocalAppData directory on Linux.
return FilePath(home_dir)
.append(FilePath(".local"))
.append(FilePath("share"));
return GetAppDataPath();
}
std::optional<FilePath> GetCommonAppDataPath() const override {
@@ -0,0 +1,36 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_G3_LINUX_PATH_UTIL_H_
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_G3_LINUX_PATH_UTIL_H_
#include <cstdlib>
#include "internal/base/file_path.h"
#include "internal/base/files.h"
namespace nearby::g3 {
inline FilePath GetAppDataPath() {
const char* home_dir = getenv("HOME");
if (home_dir == nullptr) {
return Files::GetTemporaryDirectory();
}
// This matches the .NET LocalAppData directory on Linux.
return FilePath(home_dir).append(FilePath(".local/share"));
}
} // namespace nearby::g3
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_G3_LINUX_PATH_UTIL_H_