Skip to content
Open
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
25 changes: 25 additions & 0 deletions Framework/PCFileCreator.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,29 @@ - (BOOL)createFiles:(NSDictionary *)fileList
return YES;
}

- (NSString *) sanitizeUppercaseFileNameString:(NSString *) input
{
NSMutableString *sanitizedString = [NSMutableString stringWithCapacity:[input length]];

// Create a character set that includes letters, digits, and the underscore character
NSMutableCharacterSet *allowedCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
[allowedCharacters addCharactersInString:@"_"];

for (NSUInteger i = 0; i < [input length]; i++)
{
unichar character = [input characterAtIndex:i];

if ([allowedCharacters characterIsMember:character])
{
[sanitizedString appendFormat:@"%C", character];
} else {
Copy link
Member

Choose a reason for hiding this comment

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

This else should be on separate lines... like so...

}
else
{

Other than that looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

[sanitizedString appendString:@"_"];
}
}

return sanitizedString;
}

- (void)replaceTagsInFileAtPath:(NSString *)newFile
withProject:(PCProject *)aProject
{
Expand All @@ -297,6 +320,8 @@ - (void)replaceTagsInFileAtPath:(NSString *)newFile
NSString *fn = [aFile stringByDeletingPathExtension];
NSRange subRange;

UCfn = [self sanitizeUppercaseFileNameString: UCfn];

#ifdef WIN32
file = [[NSMutableString stringWithContentsOfFile: newFile
encoding: NSUTF8StringEncoding
Expand Down