Refactor Input/Output file to use const char* instead of standard string, and to use parent_folder and file_name for input and output files. This also incorporates the move from nearby_connections to nearby.

PiperOrigin-RevId: 418002199
This commit is contained in:
jfcarroll
2021-12-23 07:04:38 -08:00
committed by Copybara-Service
parent 8f20fecfab
commit 9ce7be9812
48 changed files with 373 additions and 541 deletions
+13 -11
View File
@@ -41,9 +41,9 @@
namespace location {
namespace nearby {
namespace api {
namespace {
std::unique_ptr<std::string> ImplementationPlatform::GetDownloadPath(
std::unique_ptr<std::string> path) {
std::string GetPayloadPath(PayloadId payload_id) {
PWSTR basePath;
// Retrieves the full path of a known folder identified by the folder's
@@ -61,12 +61,13 @@ std::unique_ptr<std::string> ImplementationPlatform::GetDownloadPath(
// is no longer needed by calling CoTaskMemFree, whether
// SHGetKnownFolderPath succeeds or not.
auto basePathLength = (wcslen(basePath) + 1) * sizeof(char);
char* fullpathUTF8 = new char(basePathLength);
wcstombs(fullpathUTF8, basePath, basePathLength);
return std::make_unique<std::string>(std::string(fullpathUTF8) +=
"/" + *path);
char* fullpathUTF8 = new char((wcslen(basePath) + 1) * sizeof(char));
wcstombs(fullpathUTF8, basePath, (wcslen(basePath) + 1) * sizeof(char));
std::string fullPath = std::string(fullpathUTF8);
auto retval = absl::StrCat(fullPath += "/", payload_id);
return retval;
}
} // namespace
std::unique_ptr<AtomicBoolean> ImplementationPlatform::CreateAtomicBoolean(
bool initial_value) {
@@ -93,13 +94,14 @@ ImplementationPlatform::CreateConditionVariable(Mutex* mutex) {
}
std::unique_ptr<InputFile> ImplementationPlatform::CreateInputFile(
const char* file_path) {
return absl::make_unique<shared::InputFile>(file_path);
PayloadId payload_id, std::int64_t total_size) {
return absl::make_unique<shared::InputFile>(GetPayloadPath(payload_id),
total_size);
}
std::unique_ptr<OutputFile> ImplementationPlatform::CreateOutputFile(
const char* file_path) {
return absl::make_unique<shared::OutputFile>(file_path);
PayloadId payload_id) {
return absl::make_unique<shared::OutputFile>(GetPayloadPath(payload_id));
}
// TODO(b/184975123): replace with real implementation.