From e25a9641915027ca5d5dd5a128367ef47139dd47 Mon Sep 17 00:00:00 2001 From: Brian Bowman Date: Mon, 13 Feb 2017 15:56:29 -0800 Subject: [PATCH 1/2] Partial revert of 8bbd30f739343b5afa73e63a33583cfda10eaf4d --- Frameworks/Starboard/EbrFile.cpp | 56 ++++--------------- .../StarboardXaml/ApplicationCompositor.cpp | 2 + Frameworks/include/Platform/EbrPlatform.h | 2 + build/Starboard/dll/Starboard.def | 1 + 4 files changed, 15 insertions(+), 46 deletions(-) diff --git a/Frameworks/Starboard/EbrFile.cpp b/Frameworks/Starboard/EbrFile.cpp index 2226cf2307..7cf78dbc7b 100644 --- a/Frameworks/Starboard/EbrFile.cpp +++ b/Frameworks/Starboard/EbrFile.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -33,16 +33,6 @@ #include "EbrDevRandomFile.h" #include "EbrStorageFile.h" -#include -#include -#include -#include -#include - -using namespace ABI::Windows::Storage; -using namespace Microsoft::WRL; -using namespace Windows::Foundation; - static const wchar_t* TAG = L"EbrFile"; std::mutex EbrFile::s_fileMapLock{}; @@ -171,46 +161,20 @@ bool EbrUnlink(const char* path) { } #define mkdir _mkdir +std::wstring g_WritableFolder(L"."); -Wrappers::HString _IwGetWritableFolder() { - Wrappers::HString toReturn; - ComPtr folder; - ComPtr applicationDataStatics; - ComPtr applicationData; - ComPtr storageItem; - - if (FAILED(GetActivationFactory(Wrappers::HStringReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), - &applicationDataStatics))) { - return toReturn; - } - - if (FAILED(applicationDataStatics->get_Current(&applicationData))) { - return toReturn; - } - - if (FAILED(applicationData->get_LocalFolder(&folder))) { - return toReturn; - } - - if (FAILED(folder.As(&storageItem))) { - return toReturn; - } - - if (FAILED(storageItem->get_Path(toReturn.GetAddressOf()))) { - return toReturn; - } - - return toReturn; +void IwSetWritableFolder(const wchar_t* folder) { + g_WritableFolder = folder; + // recreate the default folders + CPathMapper::CreateDefaultPaths(); } const wchar_t* IwGetWritableFolder() { - static Wrappers::HString basePath = _IwGetWritableFolder(); - - if (!basePath.IsValid()) { - return L"."; - } + return g_WritableFolder.c_str(); +} - return WindowsGetStringRawBuffer(basePath.Get(), nullptr); +const std::wstring& _IwGetWritableFolder() { + return g_WritableFolder; } bool EbrMkdir(const char* path) { diff --git a/Frameworks/UIKit/StarboardXaml/ApplicationCompositor.cpp b/Frameworks/UIKit/StarboardXaml/ApplicationCompositor.cpp index 42f5f97d29..514e2ad54b 100644 --- a/Frameworks/UIKit/StarboardXaml/ApplicationCompositor.cpp +++ b/Frameworks/UIKit/StarboardXaml/ApplicationCompositor.cpp @@ -38,6 +38,8 @@ void InitializeApp() { } initialized = true; + // Set our writable and temp folders + IwSetWritableFolder(Windows::Storage::ApplicationData::Current->LocalFolder->Path->Data()); SetTemporaryFolder(Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data()); // Set the waiter routine for the main runloop to yield diff --git a/Frameworks/include/Platform/EbrPlatform.h b/Frameworks/include/Platform/EbrPlatform.h index 9d2bb1ff03..57d8d8b60c 100644 --- a/Frameworks/include/Platform/EbrPlatform.h +++ b/Frameworks/include/Platform/EbrPlatform.h @@ -83,6 +83,8 @@ SB_EXPORT double EbrGetMediaTime(); SB_EXPORT int EbrGetWantedOrientation(); SB_EXPORT const wchar_t* IwGetWritableFolder(); +SB_EXPORT void IwSetWritableFolder(const wchar_t* folder); + SB_EXPORT void EbrBlockIfBackground(); typedef void* EbrEvent; diff --git a/build/Starboard/dll/Starboard.def b/build/Starboard/dll/Starboard.def index acedce19f2..3b8023c58d 100644 --- a/build/Starboard/dll/Starboard.def +++ b/build/Starboard/dll/Starboard.def @@ -174,6 +174,7 @@ LIBRARY Starboard EbrEventDestroy IwGetWritableFolder + IwSetWritableFolder ; REMOVE / CLEANUP C++ EXPORTS ?format@string@woc@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBDZZ From 22c8edb20dc78a45189b36a7a7e0846af8276699 Mon Sep 17 00:00:00 2001 From: Brian Bowman Date: Mon, 13 Feb 2017 19:33:44 -0800 Subject: [PATCH 2/2] s --- tests/unittests/Foundation/ReferenceFoundation/TestNSData.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittests/Foundation/ReferenceFoundation/TestNSData.mm b/tests/unittests/Foundation/ReferenceFoundation/TestNSData.mm index 8e18959933..eafa41ad2c 100644 --- a/tests/unittests/Foundation/ReferenceFoundation/TestNSData.mm +++ b/tests/unittests/Foundation/ReferenceFoundation/TestNSData.mm @@ -28,7 +28,7 @@ TEST(NSData, WriteToURLOptions) { NSData* saveData = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"Test" withExtension:@"plist"]]; - auto savePath = @"/tmp/Test.plist"; + auto savePath = @"Test.plist"; NSError* error = nil; [saveData writeToFile:savePath options:NSDataWritingAtomic error:&error];