DBUtil.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // DBUtil.m
  3. // iSales-USAI
  4. //
  5. // Created by Rui Zhang on 11/11/21.
  6. // Copyright © 2021 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "DBUtil.h"
  9. #import "ZipArchive.h"
  10. @implementation DBUtil
  11. +(NSString*) getdbzip:(NSString*)dbname
  12. {
  13. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
  14. NSString *documents = /*[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];*/[paths objectAtIndex:0];
  15. NSString *database_path = [documents stringByAppendingPathComponent:dbname];
  16. NSString* temp = NSTemporaryDirectory();
  17. NSString* uuid=[[NSUUID UUID] UUIDString];
  18. NSString *tempfile = [temp stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",uuid]];
  19. ZipArchive* zip = [[ZipArchive alloc] init];
  20. BOOL result = [zip CreateZipFile2:tempfile Password:@"usai2010"];
  21. result = [zip addFileToZip:database_path newname:[database_path lastPathComponent]];
  22. return tempfile;
  23. }
  24. @end