| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- //
- // DBUtil.m
- // iSales-USAI
- //
- // Created by Rui Zhang on 11/11/21.
- // Copyright © 2021 United Software Applications, Inc. All rights reserved.
- //
- #import "DBUtil.h"
- #import "ZipArchive.h"
- @implementation DBUtil
- +(NSString*) getdbzip:(NSString*)dbname
- {
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- NSString *documents = /*[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];*/[paths objectAtIndex:0];
- NSString *database_path = [documents stringByAppendingPathComponent:dbname];
- NSString* temp = NSTemporaryDirectory();
- NSString* uuid=[[NSUUID UUID] UUIDString];
- NSString *tempfile = [temp stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",uuid]];
- ZipArchive* zip = [[ZipArchive alloc] init];
- BOOL result = [zip CreateZipFile2:tempfile Password:@"usai2010"];
- result = [zip addFileToZip:database_path newname:[database_path lastPathComponent]];
- return tempfile;
- }
- @end
|