[vlc-commits] macosx: remove VLCByteCountFormatter

Felix Paul Kühne git at videolan.org
Mon Jun 3 11:34:57 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon Jun  3 11:27:10 2019 +0200| [c72a2cb1490151aaa3cfca4923175ab75e8a1f5c] | committer: Felix Paul Kühne

macosx: remove VLCByteCountFormatter

Targetted macOS versions include NSByteFormatter which should be used instead.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c72a2cb1490151aaa3cfca4923175ab75e8a1f5c
---

 modules/gui/macosx/extensions/misc.h |  8 -----
 modules/gui/macosx/extensions/misc.m | 68 ------------------------------------
 2 files changed, 76 deletions(-)

diff --git a/modules/gui/macosx/extensions/misc.h b/modules/gui/macosx/extensions/misc.h
index 0317ae718e..75b3474464 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
- *****************************************************************************/
-
- at interface VLCByteCountFormatter : NSFormatter
-+ (NSString *)stringFromByteCount:(long long)byteCount countStyle:(NSByteCountFormatterCountStyle)countStyle;
- at end
diff --git a/modules/gui/macosx/extensions/misc.m b/modules/gui/macosx/extensions/misc.m
index d81d758c56..2f46b73e14 100644
--- a/modules/gui/macosx/extensions/misc.m
+++ b/modules/gui/macosx/extensions/misc.m
@@ -68,71 +68,3 @@
 }
 
 @end
-
-/*****************************************************************************
- * VLCByteCountFormatter addition
- *****************************************************************************/
-
- at 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;
-}
-
- at end



More information about the vlc-commits mailing list