//
//  NSURL+gmsafekit.m
//  HiSports
//
//  Created by luxiaoming on 16/10/11.
//  Copyright © 2016年 com.ouj. All rights reserved.
//

#import "NSURL+gmsafekit.h"

@implementation NSURL (gmsafekit)

+ (NSURL *)safeFileURLWithPath:(NSString *)path {
    if (path && path.length > 0) {
        return [NSURL fileURLWithPath:path];
    } else {
        return nil;
    }
}

+ (NSURL *)safeFileURLWithPath:(NSString *)path isDirectory:(BOOL)isDir NS_AVAILABLE(10_5, 2_0) {
    if (path && path.length > 0) {
        return [NSURL fileURLWithPath:path isDirectory:isDir];
    } else {
        return nil;
    }
}

- (instancetype)safeInitWithString:(NSString *)URLString {
    if (URLString && URLString.length > 0) {
        return [[NSURL alloc] initWithString:URLString];
    } else {
        return nil;
    }
}

@end
