Files
core/DesktopEditor/common/NSFileManager+Utils.m
Alexey.Musinov 19219bbf67 [ios] update
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@64998 954022d7-b5bf-4e40-9824-e11837661b57
2016-05-21 00:33:55 +03:00

50 lines
1.4 KiB
Objective-C

//
// NSFileManager+Utils.m
// Utils
//
// Created by alexey.musinov on 21.09.15.
// Copyright © 2015 Ascensio System SIA. All rights reserved.
//
#import "NSFileManager+Utils.h"
@implementation NSFileManager(Utils)
- (BOOL)copyFolderAtPath:(NSString*)sourceFolder toDestinationFolderAtPath:(NSString*)destinationFolder {
destinationFolder = [destinationFolder stringByAppendingPathComponent:[sourceFolder lastPathComponent]];
NSError * error = nil;
if ([self fileExistsAtPath:destinationFolder])
{
if (![self removeItemAtPath:destinationFolder error:&error])
{
NSLog(@"Could not remove old files. Error:%@",error);
return NO;
}
}
error = nil;
if (!([self copyItemAtPath:sourceFolder toPath:destinationFolder error:&error]))
{
NSLog(@"Could not copy report at path %@ to path %@. error %@",sourceFolder, destinationFolder, error);
return NO;
}
return YES;
}
- (NSString*)createTemporaryDirectory {
NSError *error = nil;
NSString* path = [NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), [NSUUID UUID].UUIDString];
if(![[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error])
{
NSLog(@"Could not creat temp path %@. error %@", path, error);
return @"";
}
return path;
}
@end