Example #1
0
void Recipe76::doStep1()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCMessageBox("iOS Only", "RecipeBook");
    return;
#else
    std::string zipFilename = "archive.zip";
    std::string filename = "test.txt";
    
    CCFileUtils* fileUtils = CCFileUtils::sharedFileUtils();
    // フルパスを取得
    std::string fullPath = fileUtils->fullPathForFilename(zipFilename.c_str());
    // archivezipファイルから test.txtデータをメモリに展開
    unsigned long size;
    unsigned char *data = fileUtils->getFileDataFromZip(fullPath.c_str(), filename.c_str(), &size);
    CCLOG("data:%08X, fullPath:%s", data, fullPath.c_str());
    std::string text;
    if (data!=NULL)
    {
        text.assign((const char*)data, size);
        //「delete [] data;」を忘れると、メモリーリークになるので注意
        delete [] data;
    }
    CCString *msg = CCString::createWithFormat("read from zip file'%s'", text.c_str());
    CCLabelTTF *label = (CCLabelTTF*)this->getChildByTag(10);
    label->setString(msg->getCString());
#endif
}
Example #2
0
void Recipe76::doStep3()
{
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
    CCMessageBox("Android Only", "RecipeBook");
    return;
#else
    unsigned long size;
    unsigned char *data;
    std::string filename = "res/drawable-mdpi/icon.png";
    std::string apkPath = getApkPath();
    CCFileUtils* fileUtils = CCFileUtils::sharedFileUtils();
    data = fileUtils->getFileDataFromZip(apkPath.c_str(),
                                         filename.c_str(), &size);
    if (data!=NULL)
    {
        // icon データ参照
        CCLabelTTF *label = (CCLabelTTF*)this->getChildByTag(10);
        label->setString("apk からアイコンデータを取得しました");
        delete [] data;
    }
#endif
}