//
//  BPDownloadContent.m
//  BreakPointDownload
//
//  Created by 黄亚州 on 2017/5/30.
//  Copyright © 2017年 黄亚州. All rights reserved.
//

#import "BPDownloadContent.h"
#import "BPFileManager.h"

@interface BPDownloadContent ()

@end

@implementation BPDownloadContent

- (void)setCacheFilePath:(NSString *)cacheFilePath {
    NSString *path = [cacheFilePath stringByReplacingOccurrencesOfString:cacheFilePath.lastPathComponent withString:@""];
    // 如果路径不存在就创建
    NSFileManager* manager = [NSFileManager defaultManager];
    if (![manager fileExistsAtPath:path]) {
        [manager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    }
    _cacheFilePath = cacheFilePath;
}

- (NSString *)getCacheFilePath{
    if (nil == _cacheFilePath) {
        _cacheFilePath = [BPFileManager getDownloadCachePathWithFilePath:(self.filePath?self.filePath:@"") WithFileName:self.fileName];
    }
    return _cacheFilePath;
}

- (long long)currentFileSize{
    return [BPFileManager getLengthForFilePath:self.cacheFilePath];
}

@end
