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

SetTempFolder() should take wchar_t instead of char so that we don't #1916

Merged
merged 3 commits into from
Feb 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 2 additions & 8 deletions Frameworks/UIKit/StarboardXaml/ApplicationCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,8 @@ void InitializeApp() {
initialized = true;

// Set our writable and temp folders
auto pathData = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
IwSetWritableFolder(pathData->Data());

char writableFolder[2048];
size_t outLen;
auto tempPathData = Windows::Storage::ApplicationData::Current->TemporaryFolder->Path;
wcstombs_s(&outLen, writableFolder, tempPathData->Data(), sizeof(writableFolder) - 1);
SetTemporaryFolder(writableFolder);
IwSetWritableFolder(Windows::Storage::ApplicationData::Current->LocalFolder->Path->Data());
SetTemporaryFolder(Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really, really silly. Why do we need to set these at runtime like this. When would this not be what we want. Seems like we should have the getters return this ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? the first one is required because starboard is removed from the application layer. The second is rather bizarre, but NSPathUtilties depends on it. Sure, NSPathUtiltities can do this instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are both silly. It doesn't make sense that the application compositor sets any sort of file system stuff. Starboard should know how to do this itself. That would be more proper encapsulation ...


In reply to: 99649338 [](ancestors = 99649338)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbowman any re-write on this should be considered through #1904. what we have is not ideal.


// Set the waiter routine for the main runloop to yield
SetupMainRunLoopTimedMultipleWaiter();
Expand Down
2 changes: 1 addition & 1 deletion Frameworks/UIKit/StarboardXaml/ApplicationMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ extern "C" int ApplicationMainStart(const char* principalName,
ActivationType activationType,
IInspectable* activationArg);

void SetTemporaryFolder(const char* folder);
void SetTemporaryFolder(const wchar_t* folder);
6 changes: 3 additions & 3 deletions Frameworks/UIKit/StarboardXaml/ApplicationMain.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//******************************************************************************
//******************************************************************************
//
// Copyright (c) Microsoft. All rights reserved.
//
Expand Down Expand Up @@ -179,6 +179,6 @@ int ApplicationMainStart(const char* principalName,
return 0;
}

void SetTemporaryFolder(const char* folder) {
NSSetTemporaryDirectory([NSString stringWithCString:folder]);
void SetTemporaryFolder(const wchar_t* folder) {
NSSetTemporaryDirectory([NSString stringWithCharacters:(const unichar*)folder length:wcslen(folder)]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have just changed this function to use NSString stringWithUTF8String, but there is no need for back and forth conversions, so just roll with UTF16.

Copy link
Contributor

@msft-Jeyaram msft-Jeyaram Feb 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:C++ style cast?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darn. If there was some way to get a HSTRING out of the layer above this one, we could pass it via the NSString HSTRING bridge. That'd save us a whole copy :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DHowett-MSFT yes, and in fact, we do get the value from a HSTRING. But this being a temp folder, it is going to be copied when added to any file path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it will be copied there anyway. It would still save a copy to not have a useless extra layer here to set it ...


In reply to: 99445013 [](ancestors = 99445013)

}