Sfoglia il codice sorgente

首次数据库创建 补充目录创建

hxb 8 anni fa
parent
commit
2627cc05e9

BIN
WSCloudStorage.xcworkspace/xcuserdata/jonathanh.xcuserdatad/UserInterfaceState.xcuserstate


+ 21 - 5
WSCloudStorage.xcworkspace/xcuserdata/jonathanh.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -42,13 +42,13 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "WSCloudStorage/CloudStorage/DB/CloudStorageDB.m"
-            timestampString = "523437510.412889"
+            timestampString = "523520360.251097"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "48"
-            endingLineNumber = "48"
-            landmarkName = "-init"
-            landmarkType = "7">
+            startingLineNumber = "82"
+            endingLineNumber = "82"
+            landmarkName = "@implementation CloudStorageDB"
+            landmarkType = "3">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
@@ -83,5 +83,21 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "WSCloudStorage/CloudStorage/DB/CloudStorageDB.m"
+            timestampString = "523520360.251097"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "56"
+            endingLineNumber = "56"
+            landmarkName = "-init"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 44 - 10
WSCloudStorage/CloudStorage/DB/CloudStorageDB.m

@@ -30,23 +30,28 @@ static CloudStorageDB *cloudStorageDB;
     return cloudStorageDB;
 
 }
-
 - (instancetype)init
 {
     if (self = [super init]) {
         
+        NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
+        // app名称
+        NSString *app_Name = [infoDictionary objectForKey:@"CFBundleName"];
         
-        NSString *localPath = [NSPersistentStore MR_defaultLocalStoreUrl].absoluteString.stringByDeletingLastPathComponent;
-        
+        NSString *appSuportPath = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,   NSUserDomainMask, YES) objectAtIndex:0];
+        BOOL isDirectory_appSuportPath = YES;
+        NSError *error;
+        NSString *localPath = [appSuportPath stringByAppendingPathComponent:app_Name];
+        BOOL existsDirectory = [[NSFileManager defaultManager]fileExistsAtPath:localPath isDirectory:&isDirectory_appSuportPath];
+        if  (!existsDirectory) {
+            [[NSFileManager defaultManager]createDirectoryAtPath:localPath withIntermediateDirectories:YES attributes:nil error:&error];
+            
+        }
         NSString *path = [NSString stringWithFormat:@"%@/%@_cloudStorageDisk.sqlite",localPath,Login_Name];
-        NSFileManager *filemanager = [NSFileManager defaultManager];
+        //BOOL existsDBfile = [[NSFileManager defaultManager]fileExistsAtPath:appSuportPath isDirectory:(BOOL*)NO];
         
-        NSString *libraryPathstr = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
-        NSString *applicationsupportdir = [libraryPathstr stringByAppendingString:@"/Application Support"];
+      
         
-        NSError *error;
-        BOOL resultlocalpath = [filemanager createDirectoryAtPath:applicationsupportdir withIntermediateDirectories:YES attributes:nil error:&error];
-        NSString *dbpath =
         //创建表
         self.dbOperation = [DBOperation dbOperationWithPath:path];
         
@@ -55,11 +60,40 @@ static CloudStorageDB *cloudStorageDB;
         [self.dbOperation creatDBWithTableName:downTransFileList dbModelClass:[CSFileDownUpModel class] Path:path autoUpgrade:YES uniqueCloumName:@"downUpUUID"];
         
         [self.dbOperation creatDBWithTableName:upTransFileList dbModelClass:[CSFileDownUpModel class] Path:path autoUpgrade:YES uniqueCloumName:@"downUpUUID"];
-
+        
     }
     
     return self;
 }
+//- (instancetype)init
+//{
+//    if (self = [super init]) {
+//        
+//        
+//        NSString *localPath = [NSPersistentStore MR_defaultLocalStoreUrl].absoluteString.stringByDeletingLastPathComponent;
+//        
+//        NSString *path = [NSString stringWithFormat:@"%@/%@_cloudStorageDisk.sqlite",localPath,Login_Name];
+//        NSFileManager *filemanager = [NSFileManager defaultManager];
+//        
+//        NSString *libraryPathstr = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
+//        NSString *applicationsupportdir = [libraryPathstr stringByAppendingString:@"/Application Support"];
+//        
+//        NSError *error;
+//        BOOL resultlocalpath = [filemanager createDirectoryAtPath:applicationsupportdir withIntermediateDirectories:YES attributes:nil error:&error];
+//        NSString *dbpath =
+//        //创建表
+//        self.dbOperation = [DBOperation dbOperationWithPath:path];
+//        
+//        [self.dbOperation creatDBWithTableName:cacheFileList dbModelClass:[CSFileModel class] Path:path autoUpgrade:YES uniqueCloumName:@"sid"];
+//        
+//        [self.dbOperation creatDBWithTableName:downTransFileList dbModelClass:[CSFileDownUpModel class] Path:path autoUpgrade:YES uniqueCloumName:@"downUpUUID"];
+//        
+//        [self.dbOperation creatDBWithTableName:upTransFileList dbModelClass:[CSFileDownUpModel class] Path:path autoUpgrade:YES uniqueCloumName:@"downUpUUID"];
+//
+//    }
+//    
+//    return self;
+//}
 
 //建立索引
 - (void)createIndexForTableName:(NSString *)name indexCloums:(NSArray<NSArray*> *)indexCloums