Skip to content
Snippets Groups Projects
Commit c72a2cb1 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

macosx: remove VLCByteCountFormatter

Targetted macOS versions include NSByteFormatter which should be used instead.
parent a5288174
No related branches found
No related tags found
No related merge requests found
......@@ -41,11 +41,3 @@
errorDescription:(NSString**)error;
@end
/*****************************************************************************
* VLCByteCountFormatter addition
*****************************************************************************/
@interface VLCByteCountFormatter : NSFormatter
+ (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle;
@end
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment