Add SetCustomSavePath API to Nearby Connections

PiperOrigin-RevId: 492563503
This commit is contained in:
Aaron Yu
2022-12-02 14:38:55 -08:00
committed by Copybara-Service
parent 2273c87b57
commit 49af1a96b6
20 changed files with 193 additions and 82 deletions
@@ -36,8 +36,20 @@ namespace location {
namespace nearby {
namespace api {
std::string ImplementationPlatform::GetDownloadPath(absl::string_view parent_folder,
absl::string_view file_name) {
std::string ImplementationPlatform::GetCustomSavePath(const std::string& parent_folder,
const std::string& file_name) {
// TODO(b/227535777): This needs to be done correctly, we now have a file name and parent folder,
// they should be combined with the custom save path
NSString* fileName = ObjCStringFromCppString(file_name);
// TODO(b/227535777): If file name matches an existing file, it will be overwritten. Append a
// number until a unique file name is reached 'foobar (2).png'.
return CppStringFromObjCString([NSTemporaryDirectory() stringByAppendingPathComponent:fileName]);
}
std::string ImplementationPlatform::GetDownloadPath(const std::string& parent_folder,
const std::string& file_name) {
// TODO(jfcarroll): This needs to be done correctly, we now have a file name and parent folder,
// they should be combined with the default download path
NSString* fileName = ObjCStringFromCppString(file_name);
@@ -84,7 +96,7 @@ std::unique_ptr<InputFile> ImplementationPlatform::CreateInputFile(PayloadId pay
return nullptr;
}
std::unique_ptr<InputFile> ImplementationPlatform::CreateInputFile(absl::string_view file_path,
std::unique_ptr<InputFile> ImplementationPlatform::CreateInputFile(const std::string& file_path,
size_t size) {
return shared::IOFile::CreateInputFile(file_path, size);
}
@@ -94,7 +106,7 @@ std::unique_ptr<OutputFile> ImplementationPlatform::CreateOutputFile(PayloadId p
return nullptr;
}
std::unique_ptr<OutputFile> ImplementationPlatform::CreateOutputFile(absl::string_view file_path) {
std::unique_ptr<OutputFile> ImplementationPlatform::CreateOutputFile(const std::string& file_path) {
return shared::IOFile::CreateOutputFile(file_path);
}
@@ -131,8 +143,8 @@ std::unique_ptr<BleMedium> ImplementationPlatform::CreateBleMedium(api::Bluetoot
return nullptr;
}
std::unique_ptr<ble_v2::BleMedium>
ImplementationPlatform::CreateBleV2Medium(api::BluetoothAdapter& adapter) {
std::unique_ptr<ble_v2::BleMedium> ImplementationPlatform::CreateBleV2Medium(
api::BluetoothAdapter& adapter) {
return std::make_unique<ios::BleMedium>(adapter);
}