-
Notifications
You must be signed in to change notification settings - Fork 806
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,9 +267,9 @@ - (NSArray*)subpathsAtPath:(NSString*)path { | |
@Notes attributes parameter not supported. error parameter not supported. | ||
*/ | ||
- (BOOL)createDirectoryAtURL:(NSURL*)url | ||
withIntermediateDirectories:(BOOL)createIntermediates | ||
attributes:(NSDictionary*)attrs | ||
error:(NSError**)err { | ||
withIntermediateDirectories:(BOOL)createIntermediates | ||
attributes:(NSDictionary*)attrs | ||
error:(NSError**)err { | ||
id path = [url path]; | ||
|
||
return [self createDirectoryAtPath:path withIntermediateDirectories:createIntermediates attributes:attrs error:err]; | ||
|
@@ -280,9 +280,9 @@ - (BOOL)createDirectoryAtURL:(NSURL*)url | |
@Notes attributes parameter not supported. error parameter is not populated | ||
*/ | ||
- (BOOL)createDirectoryAtPath:(NSString*)pathAddr | ||
withIntermediateDirectories:(BOOL)createIntermediates | ||
attributes:(NSDictionary*)attrs | ||
error:(NSError**)err { | ||
withIntermediateDirectories:(BOOL)createIntermediates | ||
attributes:(NSDictionary*)attrs | ||
error:(NSError**)err { | ||
if (createIntermediates) { | ||
const char* path = [pathAddr UTF8String]; | ||
id components = [pathAddr pathComponents]; | ||
|
@@ -400,11 +400,10 @@ - (BOOL)copyItemAtPath:(id)srcPath toPath:(id)destPath error:(NSError**)error { | |
[outputStream open]; | ||
[inputStream open]; | ||
auto closeStreams = wil::ScopeExit([&outputStream, &inputStream]() { | ||
[outputStream close]; | ||
[inputStream close]; | ||
[outputStream close]; | ||
[inputStream close]; | ||
}); | ||
|
||
|
||
if (NSStreamStatusOpen != inputStream.streamStatus) { | ||
TraceError(TAG, L"Error opening %hs", src); | ||
return NO; | ||
|
@@ -417,7 +416,6 @@ - (BOOL)copyItemAtPath:(id)srcPath toPath:(id)destPath error:(NSError**)error { | |
|
||
uint8_t in[4096]; | ||
while ([inputStream hasBytesAvailable]) { | ||
|
||
NSInteger readResult = [inputStream read:in maxLength:_countof(in)]; | ||
if (readResult == -1) { | ||
return NO; | ||
|
@@ -427,7 +425,6 @@ - (BOOL)copyItemAtPath:(id)srcPath toPath:(id)destPath error:(NSError**)error { | |
const unsigned char* baseAddress = (const unsigned char*)in; | ||
|
||
while (bytesToWrite > 0) { | ||
|
||
auto result = [outputStream write:(baseAddress + (readResult - bytesToWrite)) maxLength:bytesToWrite]; | ||
if (result == -1) { | ||
return NO; | ||
|
@@ -844,7 +841,7 @@ - (const char*)fileSystemRepresentationWithPath:(id)pathAddr { | |
*/ | ||
- (id)stringWithFileSystemRepresentation:(const char*)path length:(NSUInteger)length { | ||
UNIMPLEMENTED(); | ||
return [NSString stringWithCString:path length:length]; | ||
return [NSString stringWithUTF8String:path length:length]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not an actual method. |
||
} | ||
|
||
// Managing the Delegate | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. . There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
// Set the waiter routine for the main runloop to yield | ||
SetupMainRunLoopTimedMultipleWaiter(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//****************************************************************************** | ||
//****************************************************************************** | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// | ||
|
@@ -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)]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:C++ style cast? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the formats got corrected here?