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
16 changes: 6 additions & 10 deletions Frameworks/Foundation/NSDictionary.mm
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ + (NSDictionary*)dictionaryWithContentsOfFile:(NSString*)filename {
@Notes Only file:// URLs supported
*/
+ (NSDictionary*)dictionaryWithContentsOfURL:(NSURL*)url {
const char* file = (char*)[[url path] UTF8String];
NSData* data = [NSData dataWithContentsOfFile:[NSString stringWithCString:file]];
NSData* data = [NSData dataWithContentsOfURL:url];
if (data == nil) {
return nil;
}
Expand All @@ -378,8 +377,7 @@ + (NSDictionary*)dictionaryWithContentsOfURL:(NSURL*)url {
@Notes Only file:// URLs supported
*/
- (NSDictionary*)initWithContentsOfURL:(id)url {
const char* file = (char*)[[url path] UTF8String];
NSData* data = [NSData dataWithContentsOfFile:[NSString stringWithCString:file]];
NSData* data = [NSData dataWithContentsOfURL:url];

NSDictionary* dictionary = nil;
if (data) {
Expand Down Expand Up @@ -800,12 +798,10 @@ - (void)enumerateKeysAndObjectsWithOptions:(NSEnumerationOptions)options usingBl
return;
}

_enumerateWithBlock([self keyEnumerator],
options,
^(id key, BOOL* stop) {
id value = [self objectForKey:key];
block(key, value, stop);
});
_enumerateWithBlock([self keyEnumerator], options, ^(id key, BOOL* stop) {
id value = [self objectForKey:key];
block(key, value, stop);
});
}

/**
Expand Down
14 changes: 7 additions & 7 deletions Frameworks/Foundation/NSDirectoryEnumerator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static void searchRecursive(const char* rootpath,
if (keys != nil) { // caller wants to fetch some properties for this URL
NSDictionary* fileAttributes = fileAttributesForFilePath(fileFullPath.c_str());
if (fileAttributes != nil) {
NSURL* newURL = [NSURL fileURLWithPath:[NSString stringWithCString:fileFullPath.c_str()]];
NSURL* newURL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:fileFullPath.c_str()]];
for (NSString* key in keys) {
if ([key isEqualToString:NSURLContentModificationDateKey]) {
// TODO 7491994: Implement CFURL resourceValue APIs
Expand All @@ -116,7 +116,7 @@ static void searchRecursive(const char* rootpath,
}

} else {
NSString* newStr = [NSString stringWithCString:filename.c_str()];
NSString* newStr = [NSString stringWithUTF8String:filename.c_str()];
[objArray addObject:newStr];
}

Expand All @@ -137,12 +137,12 @@ static void searchRecursive(const char* rootpath,
@Public No
*/
- (instancetype)_initWithPath:(const char*)path
shallow:(BOOL)shallow
includingPropertiesForKeys:(NSArray*)keys
options:(NSDirectoryEnumerationOptions)mask
returnNSURL:(BOOL)returnNSURL {
shallow:(BOOL)shallow
includingPropertiesForKeys:(NSArray*)keys
options:(NSDirectoryEnumerationOptions)mask
returnNSURL:(BOOL)returnNSURL {
_rootFiles.attach([NSMutableArray new]);
_searchPath = [NSString stringWithCString:path];
_searchPath = [NSString stringWithUTF8String:path];
searchRecursive(path, "", shallow, _rootFiles, keys, mask, returnNSURL);
_currrentEnumerator.push_back([_rootFiles objectEnumerator]);
_currentDepth = 0;
Expand Down
21 changes: 9 additions & 12 deletions Frameworks/Foundation/NSFileManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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?

attributes:(NSDictionary*)attrs
error:(NSError**)err {
id path = [url path];

return [self createDirectoryAtPath:path withIntermediateDirectories:createIntermediates attributes:attrs error:err];
Expand All @@ -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];
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not an actual method.

}

// Managing the Delegate
Expand Down
6 changes: 3 additions & 3 deletions Frameworks/UIKit/UIImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ - (instancetype)initWithContentsOfFile:(NSString*)pathAddr {

if (EbrAccess(pathStr, 0) == -1) {
id pathFind =
[bundle pathForResource:[NSString stringWithCString:newStr] ofType:nil inDirectory:nil forLocalization:@"English"];
[bundle pathForResource:[NSString stringWithUTF8String:newStr] ofType:nil inDirectory:nil forLocalization:@"English"];

if (pathFind != nil) {
path = (char*)[pathFind UTF8String];
Expand Down Expand Up @@ -359,7 +359,7 @@ - (instancetype)initWithContentsOfFile:(NSString*)pathAddr {
}

const UIImageCachedObject* cachedImage =
reinterpret_cast<const UIImageCachedObject*>(CFDictionaryGetValue(g_imageCache, [NSString stringWithCString:pathStr]));
reinterpret_cast<const UIImageCachedObject*>(CFDictionaryGetValue(g_imageCache, [NSString stringWithUTF8String:pathStr]));

if (cachedImage) {
if (pathStr) {
Expand Down Expand Up @@ -399,7 +399,7 @@ - (instancetype)initWithContentsOfFile:(NSString*)pathAddr {
_imageStretch.size.height = 1.0f;

// Cache the image
_cacheImage = [UIImage cacheImage:self withName:[NSString stringWithCString:pathStr]];
_cacheImage = [UIImage cacheImage:self withName:[NSString stringWithUTF8String:pathStr]];

if (pathStr) {
IwFree(pathStr);
Expand Down
Loading