Cocos2d-x 파일 저장 소스

SMART_Phone/cocos2d-x 2011. 8. 9. 11:54 Posted by Request

char *SaveBuffer;
char tempBuffer[1024];
int tempLen = 0;

tempLen = STRLEN(tempBuffer);
 SaveBuffer = (char*)MALLOC(tempLen+ 1 + sizeof(int));
MEMSET(SaveBuffer, NULL, tempLen + 1 + sizeof(int));
MEMCPY(SaveBuffer, &tempLen, sizeof(int));

 //NSData *myData = [NSData dataWithBytes:SaveBuffer length:dwSaveDataSize];
 //[[NSUserDefaults standardUserDefaults] setObject:myData forKey:[NSString stringWithUTF8String:STORY_DATAFILE]];

 if(m_pMain->m_iDifficultyLevel == EASY_MODE){
  std::string pathKey = CCFileUtils::fullPathFromRelativePath(EASY_STORY_DATAFILE);

  FILE *fp = fopen(pathKey.c_str(), "wb");
  if (! fp)
  {
   CCLOG("can not create file %s", path.c_str());
   return false;
  }

  fwrite(SaveBuffer , dwSaveDataSize , 1 , fp);
  fclose(fp);
  //[[NSUserDefaults standardUserDefaults] setObject:myData forKey:[NSString stringWithUTF8String:EASY_STORY_DATAFILE]];