]> git.saurik.com Git - cydia.git/commitdiff
Adding file from backup iphone.
authorJay Freeman (saurik) <saurik@saurk.com>
Wed, 10 Sep 2008 02:06:39 +0000 (02:06 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:08:28 +0000 (07:08 +0000)
UICaboodle/UCString.h [new file with mode: 0644]

diff --git a/UICaboodle/UCString.h b/UICaboodle/UCString.h
new file mode 100644 (file)
index 0000000..77ee6a1
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef UICABOODLE_UCSTRING_H
+#define UICABOODLE_UCSTRING_H
+
+#import <Foundation/NSString.h>
+
+@interface NSString (UICaboodle)
++ (NSString *) stringWithDataSize:(double)size;
+@end
+
+@implementation NSString (UICaboodle)
+
++ (NSString *) stringWithDataSize:(double)size {
+    unsigned power = 0;
+    while (size > 1024) {
+        size /= 1024;
+        ++power;
+    }
+
+    static const char *powers_[] = {"B", "KiB", "MiB", "GiB"};
+
+    return [NSString stringWithFormat:@"%.1f%s", size, powers_[power]];
+}
+
+@end
+
+#endif/*UICABOODLE_UCSTRING_H*/