diff --git a/modules/gui/macosx/extensions/misc.h b/modules/gui/macosx/extensions/misc.h index 0317ae718e82f62f19e3f875ff6e39fe629be685..75b34744649be1d14da9e58f19e216108c913173 100644 --- a/modules/gui/macosx/extensions/misc.h +++ b/modules/gui/macosx/extensions/misc.h @@ -41,11 +41,3 @@ errorDescription:(NSString**)error; @end - -/***************************************************************************** - * VLCByteCountFormatter addition - *****************************************************************************/ - -@interface VLCByteCountFormatter : NSFormatter -+ (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle; -@end diff --git a/modules/gui/macosx/extensions/misc.m b/modules/gui/macosx/extensions/misc.m index d81d758c56f73a470dd60eead52082dcdcceaae4..2f46b73e145c26a85c733afe586c1b1d6bbaf426 100644 --- a/modules/gui/macosx/extensions/misc.m +++ b/modules/gui/macosx/extensions/misc.m @@ -68,71 +68,3 @@ } @end - -/***************************************************************************** - * VLCByteCountFormatter addition - *****************************************************************************/ - -@implementation VLCByteCountFormatter - -+ (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle -{ - // Use native implementation on >= mountain lion - Class byteFormatterClass = NSClassFromString(@"NSByteCountFormatter"); - if (byteFormatterClass && [byteFormatterClass respondsToSelector:@selector(stringFromByteCount:countStyle:)]) { - return [byteFormatterClass stringFromByteCount:byteCount countStyle:NSByteCountFormatterCountStyleFile]; - } - - float devider = 0.; - float returnValue = 0.; - NSString *suffix; - - NSNumberFormatter *theFormatter = [[NSNumberFormatter alloc] init]; - [theFormatter setLocale:[NSLocale currentLocale]]; - [theFormatter setAllowsFloats:YES]; - - NSString *returnString = @""; - - if (countStyle != NSByteCountFormatterCountStyleDecimal) - devider = 1024.; - else - devider = 1000.; - - if (byteCount < 1000) { - returnValue = byteCount; - suffix = _NS("B"); - [theFormatter setMaximumFractionDigits:0]; - goto end; - } - - if (byteCount < 1000000) { - returnValue = byteCount / devider; - suffix = _NS("KB"); - [theFormatter setMaximumFractionDigits:0]; - goto end; - } - - if (byteCount < 1000000000) { - returnValue = byteCount / devider / devider; - suffix = _NS("MB"); - [theFormatter setMaximumFractionDigits:1]; - goto end; - } - - [theFormatter setMaximumFractionDigits:2]; - if (byteCount < 1000000000000) { - returnValue = byteCount / devider / devider / devider; - suffix = _NS("GB"); - goto end; - } - - returnValue = byteCount / devider / devider / devider / devider; - suffix = _NS("TB"); - -end: - returnString = [NSString stringWithFormat:@"%@ %@", [theFormatter stringFromNumber:[NSNumber numberWithFloat:returnValue]], suffix]; - - return returnString; -} - -@end