Skip to content

Instantly share code, notes, and snippets.

@talentless
Created March 12, 2012 14:53
Show Gist options
  • Save talentless/2022448 to your computer and use it in GitHub Desktop.
Save talentless/2022448 to your computer and use it in GitHub Desktop.
NSString *ccRemoveHDSuffixFromFile( NSString *path )
{
#if CC_IS_RETINA_DISPLAY_SUPPORTED
if( CC_CONTENT_SCALE_FACTOR() >= 2 ) {
NSString *name = [path lastPathComponent];
// check if path already has the suffix.
if( [name rangeOfString:CC_RETINA_IPAD_DISPLAY_FILENAME_SUFFIX].location != NSNotFound ) {
CCLOG(@"cocos2d: Filename(%@) contains %@ suffix. Removing it. See cocos2d issue #1040", path, CC_RETINA_IPAD_DISPLAY_FILENAME_SUFFIX);
NSString *newLastname = [name stringByReplacingOccurrencesOfString:CC_RETINA_IPAD_DISPLAY_FILENAME_SUFFIX withString:@""];
NSString *pathWithoutLastname = [path stringByDeletingLastPathComponent];
return [pathWithoutLastname stringByAppendingPathComponent:newLastname];
} else if( [name rangeOfString:CC_RETINA_DISPLAY_FILENAME_SUFFIX].location != NSNotFound ) {
CCLOG(@"cocos2d: Filename(%@) contains %@ suffix. Removing it. See cocos2d issue #1040", path, CC_RETINA_DISPLAY_FILENAME_SUFFIX);
NSString *newLastname = [name stringByReplacingOccurrencesOfString:CC_RETINA_DISPLAY_FILENAME_SUFFIX withString:@""];
NSString *pathWithoutLastname = [path stringByDeletingLastPathComponent];
return [pathWithoutLastname stringByAppendingPathComponent:newLastname];
}
}
#endif // CC_IS_RETINA_DISPLAY_SUPPORTED
return path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment