mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Fixed the file implementations, they weren't using a mode, and the base path was always set to /tmp/.
We now get the systems idea of where the users download folder is and use that as the base path when receiving a file. PiperOrigin-RevId: 406406731
This commit is contained in:
committed by
Copybara-Service
parent
acf516189b
commit
44fad7d8fb
@@ -14,6 +14,8 @@
|
||||
|
||||
#include "platform/impl/windows/test_utils.h"
|
||||
|
||||
#include <shlobj.h>
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
|
||||
namespace test_utils {
|
||||
@@ -29,8 +31,27 @@ std::wstring StringToWideString(const std::string& s) {
|
||||
}
|
||||
|
||||
std::string GetPayloadPath(location::nearby::PayloadId payload_id) {
|
||||
auto returnString = absl::StrCat("/tmp/", payload_id);
|
||||
PWSTR basePath;
|
||||
|
||||
return returnString;
|
||||
// Retrieves the full path of a known folder identified by the folder's
|
||||
// KNOWNFOLDERID.
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath
|
||||
SHGetKnownFolderPath(
|
||||
FOLDERID_Downloads, // rfid: A reference to the KNOWNFOLDERID that
|
||||
// identifies the folder.
|
||||
0, // dwFlags: Flags that specify special retrieval options.
|
||||
NULL, // hToken: An access token that represents a particular user.
|
||||
&basePath); // ppszPath: When this method returns, contains the address
|
||||
// of a pointer to a null-terminated Unicode string that
|
||||
// specifies the path of the known folder. The calling
|
||||
// process is responsible for freeing this resource once it
|
||||
// is no longer needed by calling CoTaskMemFree, whether
|
||||
// SHGetKnownFolderPath succeeds or not.
|
||||
|
||||
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 test_utils
|
||||
|
||||
Reference in New Issue
Block a user