better to do that in this way
authorkoda
Fri, 13 Aug 2010 02:44:44 +0200
changeset 3738 f10626e18b8a
parent 3737 2ba6ac8a114b
child 3739 97cf933e5bd2
better to do that in this way
project_files/HedgewarsMobile/Classes/MainMenuViewController.m
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Fri Aug 13 02:13:18 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Fri Aug 13 02:44:44 2010 +0200
@@ -61,9 +61,10 @@
     NSString *fileToCheck, *teamToCheck, *teamToUpdate, *schemeToCheck, *schemeToUpdate;
     NSString *resDir = [[NSBundle mainBundle] resourcePath];
     
-    NSString *dirToCheck = [NSString stringWithFormat:@"%@/Settings/", resDir];
-    if ([[NSFileManager defaultManager] fileExistsAtPath:dirToCheck] == YES) {
-
+    NSString *dirToCheck = [NSString stringWithFormat:@"%@/done.txt",DOCUMENTS_FOLDER()];
+    if ([[NSFileManager defaultManager] fileExistsAtPath:dirToCheck] == NO) {
+        DLog(@"Creating necessary files");
+        
         // if the settings file is already present, we merge current preferences with the update
         fileToCheck = [NSString stringWithFormat:@"%@/Settings/settings.plist",resDir];
         if ([[NSFileManager defaultManager] fileExistsAtPath:SETTINGS_FILE()]) {
@@ -126,8 +127,12 @@
             createWeaponNamed(@"Minefield", 5);
         }
         
-        // clean this dir so that it doesn't get called again
-        [[NSFileManager defaultManager] removeItemAtPath:dirToCheck error:&err];
+        // create a dummy file so that it doesn't get called again
+        if ([[NSFileManager defaultManager] createFileAtPath:dirToCheck 
+                                                    contents:[NSData dataWithContentsOfFile:SETTINGS_FILE()]
+                                                  attributes:nil])
+            DLog(@"Success");
+        
         if (err != nil) 
             DLog(@"%@", err);
     }
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Fri Aug 13 02:13:18 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Fri Aug 13 02:44:44 2010 +0200
@@ -113,7 +113,6 @@
 		6183D83E11E2BCE200A88903 /* LI-ipad-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 6183D83C11E2BCE200A88903 /* LI-ipad-Landscape.png */; };
 		6183D83F11E2BCE200A88903 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 6183D83D11E2BCE200A88903 /* Default.png */; };
 		6187AEBD120781B900B31A27 /* Settings in Resources */ = {isa = PBXBuildFile; fileRef = 6187AEA5120781B900B31A27 /* Settings */; };
-		6187AEBE120781C000B31A27 /* Settings in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6187AEA5120781B900B31A27 /* Settings */; };
 		619C09EA11E8B8D600F1DF16 /* title_small.png in Resources */ = {isa = PBXBuildFile; fileRef = 619C09E911E8B8D600F1DF16 /* title_small.png */; };
 		61A1188511683A8C00359010 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61A117FE1168322700359010 /* CoreGraphics.framework */; settings = {ATTRIBUTES = (Required, ); }; };
 		61A118D311683CD100359010 /* HedgewarsTitle.png in Resources */ = {isa = PBXBuildFile; fileRef = 611FD9CB1155A28C00C2203D /* HedgewarsTitle.png */; };
@@ -685,19 +684,6 @@
 		};
 /* End PBXContainerItemProxy section */
 
-/* Begin PBXCopyFilesBuildPhase section */
-		6187AE9E12077F9600B31A27 /* CopyFiles */ = {
-			isa = PBXCopyFilesBuildPhase;
-			buildActionMask = 2147483647;
-			dstPath = .;
-			dstSubfolderSpec = 7;
-			files = (
-				6187AEBE120781C000B31A27 /* Settings in CopyFiles */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXCopyFilesBuildPhase section */
-
 /* Begin PBXFileReference section */
 		1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
 		1D6058910D05DD3D006BFB54 /* Hedgewars.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Hedgewars.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1372,7 +1358,6 @@
 				1D60588D0D05DD3D006BFB54 /* Resources */,
 				1D60588E0D05DD3D006BFB54 /* Sources */,
 				1D60588F0D05DD3D006BFB54 /* Frameworks */,
-				6187AE9E12077F9600B31A27 /* CopyFiles */,
 			);
 			buildRules = (
 				9283015B0F10E46D00CC5A3C /* PBXBuildRule */,