mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Ban use of std::filesystem from nearby/sharing.
PiperOrigin-RevId: 762119139
This commit is contained in:
committed by
Copybara-Service
parent
ec7dbcbf30
commit
96a274a58f
@@ -28,9 +28,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem> // NOLINT
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
@@ -39,6 +37,7 @@
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/base/files.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/platform/implementation/atomic_boolean.h"
|
||||
#include "internal/platform/implementation/atomic_reference.h"
|
||||
#include "internal/platform/implementation/awdl.h"
|
||||
@@ -218,14 +217,13 @@ std::unique_ptr<OutputFile> ImplementationPlatform::CreateOutputFile(
|
||||
|
||||
std::unique_ptr<OutputFile> ImplementationPlatform::CreateOutputFile(
|
||||
const std::string& file_path) {
|
||||
std::filesystem::path path = std::filesystem::u8path(file_path);
|
||||
std::filesystem::path folder_path = path.parent_path();
|
||||
FilePath path{file_path};
|
||||
FilePath folder_path = path.GetParentPath();
|
||||
// Verifies that a path is a valid directory.
|
||||
if (!sharing::DirectoryExists(folder_path)) {
|
||||
if (!sharing::CreateDirectories(folder_path)) {
|
||||
if (!sharing::DirectoryExists(folder_path.GetPath())) {
|
||||
if (!sharing::CreateDirectories(folder_path.GetPath())) {
|
||||
LOG(ERROR) << "Failed to create directory: "
|
||||
<< windows::string_utils::WideStringToString(
|
||||
folder_path.wstring());
|
||||
<< folder_path.ToString();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -671,10 +671,10 @@ cc_test(
|
||||
srcs = ["nearby_sharing_settings_test.cc"],
|
||||
deps = [
|
||||
":nearby_sharing_service",
|
||||
"//internal/base:files",
|
||||
"//internal/platform/implementation/g3", # fixdeps: keep
|
||||
"//internal/test",
|
||||
"//sharing/common",
|
||||
"//sharing/common:compatible_u8_string",
|
||||
"//sharing/common:enum",
|
||||
"//sharing/internal/test:nearby_test",
|
||||
"//sharing/local_device_data:test_support",
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "sharing/nearby_sharing_settings.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem> // NOLINT(build/c++17)
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -27,9 +26,9 @@
|
||||
#include "absl/synchronization/notification.h"
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "internal/base/files.h"
|
||||
#include "internal/test/fake_device_info.h"
|
||||
#include "internal/test/fake_task_runner.h"
|
||||
#include "sharing/common/compatible_u8_string.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/common/nearby_share_prefs.h"
|
||||
#include "sharing/internal/test/fake_context.h"
|
||||
@@ -170,8 +169,7 @@ class NearbyShareSettingsTest : public ::testing::Test {
|
||||
|
||||
TEST_F(NearbyShareSettingsTest, GetAndSetCustomSavePath) {
|
||||
absl::Notification notification;
|
||||
std::string save_path =
|
||||
GetCompatibleU8String(std::filesystem::temp_directory_path().u8string());
|
||||
std::string save_path = GetTemporaryDirectory()->ToString();
|
||||
settings()->SetCustomSavePathAsync(save_path,
|
||||
[&]() { notification.Notify(); });
|
||||
Flush();
|
||||
|
||||
Reference in New Issue
Block a user