From 83b9d5c682b21d88133f24da0f94dd56bd79e687 Mon Sep 17 00:00:00 2001 From: 单军华 Date: Thu, 19 Jul 2018 13:38:55 +0800 Subject: [PATCH] change --- screendisplay/Pods/ZFDownload/ZFDownload/ZFCommonHelper.m | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 106 insertions(+), 0 deletions(-) diff --git a/screendisplay/Pods/ZFDownload/ZFDownload/ZFCommonHelper.m b/screendisplay/Pods/ZFDownload/ZFDownload/ZFCommonHelper.m new file mode 100755 index 0000000..4ef153f --- /dev/null +++ b/screendisplay/Pods/ZFDownload/ZFDownload/ZFCommonHelper.m @@ -0,0 +1,106 @@ +// +// ZFCommonHelper.m +// +// Copyright (c) 2016��� ��������� ( http://github.com/renzifeng ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "ZFCommonHelper.h" +#import "ZFFileModel.h" + +@implementation ZFCommonHelper + ++ (NSString *)getFileSizeString:(NSString *)size +{ + if([size floatValue]>=1024*1024)//������1M���������������M������������������ + { + return [NSString stringWithFormat:@"%1.2fM",[size floatValue]/1024/1024]; + } + else if([size floatValue]>=1024&&[size floatValue]<1024*1024) //������1M,���������������1KB���������������KB������ + { + return [NSString stringWithFormat:@"%1.2fK",[size floatValue]/1024]; + } + else//���������������������1K������������������B������ + { + return [NSString stringWithFormat:@"%1.2fB",[size floatValue]]; + } +} + ++ (float)getFileSizeNumber:(NSString *)size +{ + NSInteger indexM=[size rangeOfString:@"M"].location; + NSInteger indexK=[size rangeOfString:@"K"].location; + NSInteger indexB=[size rangeOfString:@"B"].location; + if(indexM<1000)//���M������������������ + { + return [[size substringToIndex:indexM] floatValue]*1024*1024; + } + else if(indexK<1000)//���K������������������ + { + return [[size substringToIndex:indexK] floatValue]*1024; + } + else if(indexB<1000)//���B������������������ + { + return [[size substringToIndex:indexB] floatValue]; + } + else//������������������������������������ + { + return [size floatValue]; + } +} + ++ (BOOL)isExistFile:(NSString *)fileName +{ + NSFileManager *fileManager = [NSFileManager defaultManager]; + return [fileManager fileExistsAtPath:fileName]; +} + ++ (NSDate *)makeDate:(NSString *)birthday +{ + NSDateFormatter *df = [[NSDateFormatter alloc] init]; + [df setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; + NSDate *date = [df dateFromString:birthday]; + return date; +} + ++ (NSString *)dateToString:(NSDate*)date +{ + NSDateFormatter *df = [[NSDateFormatter alloc] init]; + [df setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; + NSString *datestr = [df stringFromDate:date]; + return datestr; +} + ++ (NSString *)createFolder:(NSString *)path +{ + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSError *error; + if(![fileManager fileExistsAtPath:path]) + { + [fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]; + if(!error) + { + NSLog(@"%@",[error description]); + + } + } + return path; +} + +@end -- Gitblit v1.8.0