Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial revert of 8bbd30f739343b5afa73e63a33583cfda10eaf4d #1957

Merged
merged 2 commits into from
Feb 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 10 additions & 46 deletions Frameworks/Starboard/EbrFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <io.h>
#include <stdlib.h>
#include <direct.h>
#include <sys/stat.h>
#include <sys\stat.h>
#include <map>
#include <climits>
#include <regex>
Expand All @@ -33,16 +33,6 @@
#include "EbrDevRandomFile.h"
#include "EbrStorageFile.h"

#include <COMIncludes.h>
#include <wrl/client.h>
#include <wrl/wrappers/corewrappers.h>
#include <windows.storage.h>
#include <COMIncludes_End.h>

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{};
Expand Down Expand Up @@ -171,46 +161,20 @@ bool EbrUnlink(const char* path) {
}

#define mkdir _mkdir
std::wstring g_WritableFolder(L".");

Wrappers::HString _IwGetWritableFolder() {
Wrappers::HString toReturn;
ComPtr<IStorageFolder> folder;
ComPtr<IApplicationDataStatics> applicationDataStatics;
ComPtr<IApplicationData> applicationData;
ComPtr<IStorageItem> 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<IStorageItem>(&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) {
Expand Down
2 changes: 2 additions & 0 deletions Frameworks/UIKit/StarboardXaml/ApplicationCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Frameworks/include/Platform/EbrPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions build/Starboard/dll/Starboard.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down