Пример #1
0
int ls(char * arg){

	File * file;
	if(strlen(arg) == 0)
		file = __getCurrentDir();
	else
		file = getFileByName(arg);

	if(file!=NULL){

		printf("ls: %s\n", file->name);

		printf(".\t..\t");

		int i;
		for(i=0;i<_FILE_CHILDREN;i++)
			if(file->children[i] != NULL){
				printf("%s\t", file->children[i]->name);
			}

		printf("\n");
		return 0;
	}

	printf("ls: not found\n");

	return -1;
}
Пример #2
0
void ChatLayer::showChatContext(float delta)
{
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	int idx = m_index-1;

	string speakStr = getFileByName(m_chatContext.at(idx).name).first + ":";
	string chatStr(m_chatContext.at(idx).chatStr);

	CCLabelTTF *nameLabel = ((CCLabelTTF*)getChildByTag(Tag_Label_Name));
	CCLabelTTF * label = ((CCLabelTTF*)getChildByTag(TAG_label));
	nameLabel->setString(speakStr.c_str());
	label->setString(chatStr.c_str());
	nameLabel->setOpacity(0);
	label->setOpacity(0);
	nameLabel->runAction(CCSequence::create(
		CCFadeTo::create(0.25f, 255)
		, NULL));
	label->runAction(CCSequence::create(
		CCFadeTo::create(0.25f, 255)
		, CCCallFunc::create(this, callfunc_selector(ChatLayer::labelFadeInEnd))
		, NULL));

	if (m_chatContext.at(idx).deltaTime > 0.1f)
	{
		mCurMusicId = Music::sharedMusicPlayer()->playEffectSound(m_chatContext.at(idx).musicFile);
		scheduleOnce(schedule_selector(ChatLayer::saidChatContextEnd), m_chatContext.at(idx).deltaTime + delta_time);//有的时间太短。、、
	}
}
Пример #3
0
bool GitFileManager::updateSingleFile( boost::shared_ptr<Diff> diff, string targetFile ){

    boost::shared_ptr<GitFile> file;
    
    //If the target file doesn't match the file in the diff, exit
    if( targetFile.size() ){
        if(diff->getFileName() != targetFile) return false;
    }

    if(diff->fileMode == Diff::FILEMODE_ADDED){
        file = boost::shared_ptr<GitFile>(new GitFile(diff->getFileName()));
        if(bPresentationHack)file = boost::shared_ptr<GitFile>(new GitFile("presentation.txt"));

        applyDiffToFile(*(file), diff, bUseSyntaxHighlighting);
        m_fileList.push_back(file);
    }
    
    else if(diff->fileMode == Diff::FILEMODE_DELETED){
        file = getFileByName(diff->getFileName());
        file->setInactive();
    }
    
    else if(diff->fileMode == Diff::FILEMODE_UPDATED){
        
        if(bPresentationHack) {
            file = getFileByName("presentation.txt");
            if(!file) {
                file = boost::shared_ptr<GitFile>(new GitFile("presentation.txt"));
                m_fileList.push_back(file);
            }
        } else {
            file = getFileByName(diff->getFileName());
        }
        
        if(file){
            if(file->active()){
                applyDiffToFile(*(file), diff, bUseSyntaxHighlighting);
            }
        }
    }
    
    return true;
}
Пример #4
0
int tree(char *a){

	File * file;

	if( strlen(a) == 0)
		file = __getCurrentDir();
	else file = getFileByName(a);

	if(file != NULL)
		__printFileTree(file);
	return 0;
}
Пример #5
0
void NitroFilesystem::flushCache()
{
    allFiles.sort(smaller); //sort by offset
    NitroFile* lastFile = allFiles.back();
    uint lastOffs = lastFile->endOffs + 0x10;
    lastOffs &= ~3;
    getFileByName("header.bin")->setUintAt(0x80, lastOffs);
    getFileByName("header.bin")->fixHeaderChecksum();
    
    for(list<NitroFile*>::iterator it = allFiles.begin(); it != allFiles.end(); it++)
        (*it)->flushCache();

    fflush(romFile);
    fclose(romFile);
    romFile = fopen(romPath, "r+b");
    if(romFile == NULL)
    {
        iprintf("ERROR: Romfile = null. Halting!\n");
        while(1);
    }
    
}
Пример #6
0
int edit(char * arg){
	openFile(arg, 0);

	File * file = getFileByName(arg);

	printf("Editing %s:\n", file->name);

	char * tmp = (char *) malloc(512);
	
	scanf("%s",tmp);
	writeFile(file,tmp, strlen(tmp));

	printf("\n");
}
Пример #7
0
int cat(char * arg){
	File * file = getFileByName(arg);

	if(file == NULL) return -1;

	char * tmp = (char*) malloc(file->size);

	readFile(file, tmp, file->size);

	printf("File %s:\n", file->name);

	printf("%s\nEOF\n", tmp);

	return 0;
}
Пример #8
0
File *DirBase::getFile(const char *fn)
{
    while(fn[0] == '.' && fn[1] == '/')
        fn += 2;

    const char *slashpos = strchr(fn, '/');
    if(!slashpos)
        return getFileByName(fn, true);

    size_t copysize = std::max<size_t>(slashpos - fn, 1); // always copy the '/' if it's the first char
    char * const dirname = (char*)VFS_STACK_ALLOC(copysize + 1);
    memcpy(dirname, fn, copysize);
    dirname[copysize] = 0;

    File *f = getFileFromSubdir(dirname, slashpos + 1);
    VFS_STACK_FREE(dirname);
    return f;
}
Пример #9
0
gkBlendFile* gkBlendLoader::loadAndCatch(const gkString& fname, int options, const gkString& scene, const gkString& group)
{
	if ((options & LO_IGNORE_CACHE_FILE) != 0)
	{
		m_activeFile = getFileByName(fname);
		if (m_activeFile != 0)
			return m_activeFile;
	}

	bool useUniqueGroup = false;
	gkString groupName = group;
	if (groupName.empty() && (options & LO_CREATE_UNIQUE_GROUP) != 0) 
	{
		groupName = gkUtils::getUniqueName("BLEND");
		useUniqueGroup = true;
	}

	bool inGlolbalPool = (options & LO_CREATE_PRIVATE_GROUP) == 0;

	gkResourceGroupManager::getSingleton().createResourceGroup(groupName, inGlolbalPool);

	//bParse::bLog::detail = gkEngine::getSingleton().getUserDefs().verbose ? 1 : 0;

	m_activeFile = new gkBlendFile(fname, groupName);

	if (m_activeFile->parse(options, scene))
	{
		m_files.push_back(m_activeFile);
		return m_activeFile;
	}
	else
	{
		delete m_activeFile;
		m_activeFile = m_files.empty() ? 0 : m_files.back();
	}

	return 0;
}
Пример #10
0
bool ChatLayer::init()
{
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0,0,0,160)) );

		CCSize winSize = CCDirector::sharedDirector()->getWinSize();

		//board
		CCSprite* board = CCSprite::create("juqing_duihuakuang.png");
		addChild(board, 2, TAG_Board);
		board->setAnchorPoint(ccp(0.5, 0));
		board->setPosition(ccp(winSize.width/2, 0));
		board->setOpacity(0);
		//next img
		BaseSprite *nextImg = BaseSprite::create("sphc_anniu_fanye.png");
		board->addChild(nextImg, 0, Tag_ImgNext);
		nextImg->setPosition(ccp(597,37));
		nextImg->setOpacity(0);
		nextImg->runAction(CCSequence::create(
			CCFadeIn::create(0.15f),
			CCRepeat::create(CCSequence::create(CCFadeOut::create(0.75f), CCFadeIn::create(0.75f), NULL), -1),
			NULL));

		//npc
		string npcFileName = getFileByName(m_chatContext.at(0).name).second;
		////////////////////////////////////////////
		if(npcFileName.empty())
		{
			CCLog("Error: %s [can't found npc imgine]", __FUNCTION__);
			npcFileName = "juqing_duihua_NPC_shenmiren.png";
		}
		////////////////////////////////////////////
		CCSprite* actorA = CCSprite::create(npcFileName.c_str());
		addChild(actorA, 1, TAG_ActorA);
		actorA->setAnchorPoint(ccp(0,0));
		actorA->setPosition(ccp(0, board->getContentSize().height-14));
		actorA->setOpacity(0);
		//actor  //yemanren   cike   fashi
		string actorFileName = getFileByName("zhujue").second;
		CCSprite* actorB = CCSprite::create(actorFileName.c_str());
		addChild(actorB, 1, TAG_ActorB);
		actorB->setAnchorPoint(ccp(1,0));
		actorB->setPosition(ccp(winSize.width, board->getContentSize().height-14));
		//		actorB->setScale(0.9);
		actorB->setOpacity(0);

		//label name
		CCLabelTTF *namelabel = CCLabelTTF::create("", fontStr_kaiti, 24);
		addChild(namelabel, 5, Tag_Label_Name);
		namelabel->setAnchorPoint(ccp(0, 0.5));
		namelabel->setPosition(ccp(20, board->getContentSize().height-42));
		namelabel->setColor(fonColor_PuTong);
		namelabel->setOpacity(0);
		//label content
		CCLabelTTF* label = CCLabelTTF::create("", fontStr_kaiti, 24, CCSize(610, 0), kCCTextAlignmentLeft);
		addChild(label, 5, TAG_label);
		label->setAnchorPoint(ccp(0,1));
		label->setColor(fonColor_FaGuang);
		label->setPosition(ccp(20, board->getContentSize().height-76));
		label->setOpacity(0);




		////////////start chat
		if(m_chatContext.at(0).name == "zhujue")
			actorB->runAction(CCFadeIn::create(0.1f));
		else
			actorA->runAction(CCFadeIn::create(0.1f));
		board->runAction(CCFadeIn::create(0.1f));
		label->runAction(CCFadeIn::create(0.1f));
		namelabel->runAction(CCFadeIn::create(0.1f));
		nextImg->runAction(CCFadeIn::create(0.15f));
		scheduleOnce(schedule_selector(ChatLayer::showChatContext), 0.05f);
		{
			mTimeEnd = false;
			mLabelFadeInEnd = false;
			++m_index;
		}

		bRet = true;
	}while(0);

	return bRet;
}
Пример #11
0
bool ChatLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
	if (   (mLabelFadeInEnd && mTimeEnd)
		|| TOUCH_ENABLE)
	{
		if (TOUCH_ENABLE)
		{
			//
			unschedule(schedule_selector(ChatLayer::showChatContext));
			unschedule(schedule_selector(ChatLayer::saidChatContextEnd));
			if (mCurMusicId != 0)
				Music::sharedMusicPlayer()->stopEffectSound(mCurMusicId);
			mCurMusicId = 0;
		}
	}
	else 
	{
		return true;
	}


	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	CCSprite *board = (CCSprite*)getChildByTag(TAG_Board);
	CCSprite *nextImg = (CCSprite*)board->getChildByTag(Tag_ImgNext);
	CCSprite *actorA = (CCSprite*)getChildByTag(TAG_ActorA);
	CCSprite *actorB = (CCSprite*)getChildByTag(TAG_ActorB);
	CCLabelTTF *label = (CCLabelTTF*)getChildByTag(TAG_label);
	CCLabelTTF *nameLabel = (CCLabelTTF*)getChildByTag(Tag_Label_Name);


	if(m_index >= m_chatContext.size())
	{
		if ( mLayerEnd) //避免渐渐消失的时候动作重复闪速
			return true;

		mLayerEnd = true;

		this->runAction(CCSequence::create(
			CCFadeTo::create(0.5f, 0)
			, CCCallFunc::create(this, SEL_CallFunc(&ChatLayer::callbackRemove))
			, NULL));

		board->runAction(CCFadeTo::create(0.25f, 0));
		actorA->runAction(CCFadeTo::create(0.25f, 0));
		actorB->runAction(CCFadeTo::create(0.25f, 0));
		label->runAction(CCFadeTo::create(0.25f, 0));
		nameLabel->runAction(CCFadeTo::create(0.25f, 0));

		nextImg->stopAllActions();
		nextImg->runAction(CCFadeTo::create(0.25f, 0));
	}
	else
	{
		mTimeEnd = false;
		mLabelFadeInEnd = false;

		//label
		label->setString("");

		//下一句对话的 Speaker是谁
		string heroName = m_chatContext.at(m_index).name;
		if(heroName == "zhujue")
		{
			actorB->runAction(CCFadeTo::create(0.1f, 255));
			actorA->runAction(CCFadeTo::create(0.1f, 0));
		} 
		else
		{
			actorA->initWithFile(getFileByName(heroName).second.c_str());
			actorA->setAnchorPoint(ccp(0,0));
			actorA->setOpacity(0);
			actorA->runAction(CCFadeTo::create(0.1f, 255));
			actorB->runAction(CCFadeTo::create(0.1f, 0));
		}

		scheduleOnce(schedule_selector(ChatLayer::showChatContext), 0.05f);
		++m_index;
	}

	return true;
}
Пример #12
0
bool ZhuShouChatLayer::init()
{
    bool bRet = false;
    do
    {
        CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0,0,0,160)) );

        CCSize winSize = CCDirector::sharedDirector()->getWinSize();

        //board
        CCSprite* board = CCSprite::create("juqing_duihuakuang.png");
        addChild(board, 2, TAG_Board);
        board->setAnchorPoint(ccp(0.5, 0));
        board->setPosition(ccp(winSize.width/2, 0));
        board->setOpacity(0);
        board->setScaleY(0.7f);
        //next img
        BaseSprite *nextImg = BaseSprite::create("sphc_anniu_fanye.png");
        board->addChild(nextImg, 0, Tag_ImgNext);
        nextImg->setPosition(ccp(597,37));
        nextImg->setOpacity(0);
        nextImg->runAction(CCSequence::create(
                               CCFadeIn::create(0.15f),
                               CCRepeat::create(CCSequence::create(CCFadeOut::create(0.75f), CCFadeIn::create(0.75f), NULL), -1),
                               NULL));

        //npc
        string npcFileName = getFileByName(getPinyinName(m_nZhuaShouId)).second;
        ////////////////////////////////////////////
        if(npcFileName.empty())
        {
            CCLog("Error: %s [can't found npc imgine]", __FUNCTION__);
            npcFileName = "juqing_duihua_NPC_shenmiren.png";
        }
        ////////////////////////////////////////////
        int x_side = 20;
        CCSprite* actorA = CCSprite::create(npcFileName.c_str());
        addChild(actorA, 3, TAG_ActorA);
        actorA->setAnchorPoint(ccp(0,0));
        actorA->setPosition(ccp(x_side,x_side));
        actorA->setOpacity(0);

        int side = 10;
        //label name
        CCLabelTTF *namelabel = CCLabelTTF::create("", fontStr_kaiti, 24);
        addChild(namelabel, 5, Tag_Label_Name);
        namelabel->setAnchorPoint(ccp(0, 0.5));
        namelabel->setPosition(ccp(20, board->getContentSize().height-42));
        namelabel->setColor(fonColor_PuTong);
        namelabel->setOpacity(0);
        //label content
        //CCLabelTTF* label = CCLabelTTF::create("", fontStr_kaiti, 24, CCSize(board->getContentSize().width - actorA->getContentSize().width - side, 0), kCCTextAlignmentLeft);
        m_nTextWidth = board->getContentSize().width - actorA->getContentSize().width - side;
        NetLabelTTF* label = NetLabelTTF::create("", fontStr_kaiti, 24);
        addChild(label, 5, TAG_label);
        label->setHorizontalAlignment(kCCTextAlignmentLeft);
        label->setAnchorPoint(ccp(0,1));
        label->setColor(fonColor_FaGuang);
        label->setPosition(ccp(actorA->getContentSize().width + side, board->getContentSize().height-145));
        label->setOpacity(0);

        actorA->runAction(CCFadeIn::create(0.0f));
        board->runAction(CCFadeIn::create(0.0f));
        label->runAction(CCFadeIn::create(0.0f));
        namelabel->runAction(CCFadeIn::create(0.0f));
        nextImg->runAction(CCFadeIn::create(0.0f));
        scheduleOnce(schedule_selector(ZhuShouChatLayer::showChatContext), 0.05f);
        {
            mTimeEnd = false;
            mLabelFadeInEnd = false;
            ++m_index;
        }

        bRet = true;
    } while(0);

    return bRet;
}