// 文件大小格式化显示
- (NSString *)convert_FileSize:(long long)file_size {
long kb = 1024;
long mb = kb * 1024;
long gb = mb * 1024;
if (file_size >= gb) {
return [NSString stringWithFormat:@"%.1f GB", (float) file_size / gb];
}
else if (file_size >= mb) {
float gc_float = (float) file_size / mb;
if (gc_float > 100) {
return [NSString stringWithFormat:@"%.0f MB", gc_float];
}
else {
return [NSString stringWithFormat:@"%.1f MB", gc_float];
}
}
else if (file_size >= kb) {
float gc_float = (float) file_size / kb;
if (gc_float > 100) {
return [NSString stringWithFormat:@"%.0f KB", gc_float];
}
else {
return [NSString stringWithFormat:@"%.1f KB", gc_float];
}
} else
return [NSString stringWithFormat:@"%lld B", file_size];
}