コード例 #1
0
ファイル: MFFileSystem.cpp プロジェクト: TurkeyMan/fuji
static int MFFileSystem_GetNumEntries(const char *pFindPattern, bool recursive, bool flatten, size_t *pStringLengths)
{
	MFFindData findData;
	MFFind *hFind;

	int numFiles = 0;

	hFind = MFFileSystem_FindFirst(MFString::Format("%s*", pFindPattern).CStr(), &findData);

	if(hFind)
	{
		*pStringLengths += MFString_Length(findData.pSystemPath) + 1;
	}

	while(hFind)
	{
		if(MFString_Compare(findData.pFilename, ".") && MFString_Compare(findData.pFilename, "..") && MFString_Compare(findData.pFilename, ".svn"))
		{
			if(findData.info.attributes & MFFA_Directory)
			{
				if(recursive)
				{
					if(flatten)
					{
						MFString newPath = MFString::Format("%s%s/", pFindPattern, findData.pFilename);
						numFiles += MFFileSystem_GetNumEntries(newPath.CStr(), recursive, flatten, pStringLengths);
					}
					else
					{
						*pStringLengths += MFString_Length(findData.pFilename) + 1;
						++numFiles;
					}
				}
			}
			else
			{
				*pStringLengths += MFString_Length(findData.pFilename) + 1;
				++numFiles;
			}
		}

		if(!MFFileSystem_FindNext(hFind, &findData))
		{
			MFFileSystem_FindClose(hFind);
			hFind = NULL;
		}
	}

	return numFiles;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: FujiGameJam/fuji
void Scan(MFString path)
{
	MFFindData fd;
	MFFind *pFind = MFFileSystem_FindFirst(MFStr("%s*", path.CStr()), &fd);
	if(pFind)
	{
		do
		{
			if(fd.attributes & MFFA_Directory)
			{
				Scan(MFString::Format("%s%s/", path.CStr(), fd.pFilename).CStr());
			}
			else
			{
				MFString ext = MFString(fd.pFilename).GetExtension();
				if(ext.Enumerate(ppFormats, sizeof(ppFormats) / sizeof(ppFormats[0])) > -1)
					models.push(MFString::Format("%s%s", path.CStr(), fd.pFilename));
			}
		}
		while(MFFileSystem_FindNext(pFind, &fd));

		MFFileSystem_FindClose(pFind);
	}
}
コード例 #3
0
ファイル: MFFileSystem.cpp プロジェクト: TurkeyMan/fuji
int MFFileSystem_AddVolume(MFMount *pMount)
{
	GET_MODULE_DATA(MFFileSystemState);

	// hook it up..
	if(!pModuleData->pMountList)
	{
		pModuleData->pMountList = pModuleData->pMountListEnd = pMount;
		pMount->pPrev = pMount->pNext = NULL;
	}
	else
	{
		MFMount *pT = pModuleData->pMountList;

		while(pT && pT->volumeInfo.priority < pMount->volumeInfo.priority)
			pT = pT->pNext;

		if(pT)
		{
			if(pT == pModuleData->pMountList)
				pModuleData->pMountList = pMount;

			pMount->pPrev = pT->pPrev;
			pMount->pNext = pT;
			pT->pPrev = pMount;

			if(pMount->pPrev)
				pMount->pPrev->pNext = pMount;
		}
		else
		{
			pMount->pPrev = pModuleData->pMountListEnd;
			pModuleData->pMountListEnd->pNext = pMount;
			pModuleData->pMountListEnd = pMount;
		}
	}

	// build toc
	if(!(pMount->volumeInfo.flags & MFMF_DontCacheTOC))
	{
		MFDebug_Assert(pModuleData->ppFileSystemList[pMount->volumeInfo.fileSystem]->callbacks.FindFirst, "Filesystem must provide a set of find functions to cache the TOC");

		MFFindData findData;
		MFFind *hFind;

		bool flatten = (pMount->volumeInfo.flags & MFMF_FlattenDirectoryStructure) != 0;
		bool recursive = (pMount->volumeInfo.flags & MFMF_Recursive) != 0;

		pMount->volumeInfo.flags |= MFMF_DontCacheTOC;

		const char *pFindPath = MFStr("%s:", pMount->volumeInfo.pVolumeName);

		// this is a crude way to check if the directory exists..
		// TODO: improve this!!
		hFind = MFFileSystem_FindFirst(MFStr("%s*", pFindPath), &findData);

		if(!hFind)
		{
			MFDebug_Warn(1, "FileSystem: Couldnt Mount FileSystem.");
			return -1;
		}

		MFFileSystem_FindClose(hFind);

		// build the TOC
		size_t stringCacheSize = 0;
		pMount->numFiles = MFFileSystem_GetNumEntries(pFindPath, recursive, flatten, &stringCacheSize);

		int sizeOfToc = sizeof(MFTOCEntry)*pMount->numFiles;
		MFTOCEntry *pTOC = (MFTOCEntry*)MFHeap_Alloc(sizeOfToc + stringCacheSize);

		char *pStringCache = (char*)pTOC + sizeOfToc;
		MFFileSystem_BuildToc(pFindPath, pTOC, NULL, pStringCache, recursive, flatten);

		pMount->pEntries = pTOC;

		pMount->volumeInfo.flags &= ~MFMF_DontCacheTOC;
	}

	return 0;
}
コード例 #4
0
ファイル: MFFileSystem.cpp プロジェクト: TurkeyMan/fuji
MFTOCEntry* MFFileSystem_BuildToc(const char *pFindPattern, MFTOCEntry *pToc, MFTOCEntry *pParent, char* &pStringCache, bool recursive, bool flatten)
{
	MFFindData findData;
	MFFind *hFind;

	hFind = MFFileSystem_FindFirst(MFString::Format("%s*", pFindPattern).CStr(), &findData);

	char *pCurrentDir = pStringCache;

	if(hFind)
	{
		MFString_Copy(pCurrentDir, findData.pSystemPath);
		pStringCache += MFString_Length(findData.pSystemPath) + 1;
	}

	while(hFind)
	{
		if(MFString_Compare(findData.pFilename, ".") && MFString_Compare(findData.pFilename, "..") && MFString_Compare(findData.pFilename, ".svn"))
		{
			if(findData.info.attributes & MFFA_Directory)
			{
				if(recursive)
				{
					MFString newPath = MFString::Format("%s%s/", pFindPattern, findData.pFilename);
					if(flatten)
					{
						pToc = MFFileSystem_BuildToc(newPath.CStr(), pToc, pParent, pStringCache, recursive, flatten);
					}
					else
					{
						size_t stringCacheSize = 0;
						pToc->numChildren = MFFileSystem_GetNumEntries(newPath.CStr(), recursive, flatten, &stringCacheSize);

						MFString_Copy(pStringCache, findData.pFilename);
						pToc->pName = pStringCache;
						pStringCache += MFString_Length(findData.pFilename)+1;

						pToc->info = findData.info;
						pToc->pFilesysData = pCurrentDir;
						pToc->pParent = pParent;

						if (pToc->numChildren)
						{
							size_t sizeOfToc = sizeof(MFTOCEntry)*pToc->numChildren;
							pToc->pChildren = (MFTOCEntry*)MFHeap_Alloc(sizeOfToc + stringCacheSize);

							char *pNewStringCache = (char*)pToc->pChildren + sizeOfToc;
							MFFileSystem_BuildToc(newPath.CStr(), pToc->pChildren, pToc, pNewStringCache, recursive, flatten);
						}
						else
							pToc->pChildren = NULL;

						++pToc;
					}
				}
			}
			else
			{
				MFString_Copy(pStringCache, findData.pFilename);
				pToc->pName = pStringCache;
				pStringCache += MFString_Length(findData.pFilename)+1;

				pToc->pFilesysData = pCurrentDir;

				pToc->pParent = pParent;
				pToc->pChildren = NULL;
				pToc->numChildren = 0;

				pToc->info = findData.info;

				++pToc;
			}
		}

		if(!MFFileSystem_FindNext(hFind, &findData))
		{
			MFFileSystem_FindClose(hFind);
			hFind = NULL;
		}
	}

	return pToc;
}
コード例 #5
0
MFTOCEntry* MFFileSystem_BuildToc(const char *pFindPattern, MFTOCEntry *pToc, MFTOCEntry *pParent, char* &pStringCache, bool recursive, bool flatten)
{
	MFFindData findData;
	MFFind *hFind;

	hFind = MFFileSystem_FindFirst(MFString::Format("%s*", pFindPattern).CStr(), &findData);

	char *pCurrentDir = pStringCache;

	if(hFind)
	{
		MFString_Copy(pCurrentDir, findData.pSystemPath);
		pStringCache += MFString_Length(findData.pSystemPath) + 1;
	}

	while(hFind)
	{
		if(MFString_Compare(findData.pFilename, ".") && MFString_Compare(findData.pFilename, "..") && MFString_Compare(findData.pFilename, ".svn"))
		{
			if(findData.attributes & MFFA_Directory)
			{
				if(recursive)
				{
					MFString newPath = MFString::Format("%s%s/", pFindPattern, findData.pFilename);
					if(flatten)
					{
						pToc = MFFileSystem_BuildToc(newPath.CStr(), pToc, pParent, pStringCache, recursive, flatten);
					}
					else
					{
						size_t stringCacheSize = 0;
						pToc->size = MFFileSystem_GetNumEntries(newPath.CStr(), recursive, flatten, &stringCacheSize);

						if(pToc->size)
						{
							MFString_Copy(pStringCache, findData.pFilename);
							pToc->pName = pStringCache;
							pStringCache += MFString_Length(findData.pFilename)+1;

							pToc->flags = MFTF_Directory;
							pToc->pFilesysData = pCurrentDir;
							pToc->pParent = pParent;
							pToc->size = 0;

							size_t sizeOfToc = sizeof(MFTOCEntry)*pToc->size;
							pToc->pChild = (MFTOCEntry*)MFHeap_Alloc(sizeof(MFTOCEntry)*sizeOfToc + stringCacheSize);

							char *pNewStringCache = ((char*)pToc->pChild)+sizeOfToc;
							MFFileSystem_BuildToc(newPath.CStr(), pToc->pChild, pToc, pNewStringCache, recursive, flatten);

							++pToc;
						}
					}
				}
			}
			else
			{
				MFString_Copy(pStringCache, findData.pFilename);
				pToc->pName = pStringCache;
				pStringCache += MFString_Length(findData.pFilename)+1;

				pToc->pFilesysData = pCurrentDir;

				pToc->pParent = pParent;
				pToc->pChild = NULL;

				MFDebug_Assert(findData.fileSize < 0x100000000LL, "Files larger than 4gb not yet supported...");
				pToc->size = (uint32)findData.fileSize;
				pToc->flags = 0;

				++pToc;
			}
		}

		if(!MFFileSystem_FindNext(hFind, &findData))
		{
			MFFileSystem_FindClose(hFind);
			hFind = NULL;
		}
	}

	return pToc;
}
コード例 #6
0
ファイル: Editor.cpp プロジェクト: KingDwag/feedback-editor
void EditorScreen::Select()
{
	gpHelp = new HelpScreen;
	gpMsgBox = new MessageBoxScreen;
	gpStringBox = new StringBoxScreen;
	gpListBox = new ListBoxScreen;
	gpComboBox = new ComboBoxScreen;
	gpFileSelector = new FileSelectorScreen;

//	pScene = dBScene::Create("s_testscene");

	gEditor.pMetronome = MFMaterial_Create("metronome");

	// load sounds
	gEditor.pStepSound = MFSound_Create("Sounds/row");
	gEditor.pChangeSound = MFSound_Create("Sounds/prompt");
	gEditor.pSaveSound = MFSound_Create("Sounds/save");
	gEditor.pClapSound = MFSound_Create("Sounds/claps");
	gEditor.pHighTickSound = MFSound_Create("Sounds/hightick");
	gEditor.pLowTickSound = MFSound_Create("Sounds/lowtick");

	if(gConfig.editor.lastOpenedChart[0])
	{
		gEditor.pSong = dBChart::LoadChart(gConfig.editor.lastOpenedChart);
		gEditor.offset = 0;
		gEditor.currentBPM = gEditor.pSong->GetStartBPM();
	}
	else
		gEditor.pSong = dBChart::Create();

	gGame.pTrack = new Fretboard;
	gGame.pTrack2 = new Fretboard;

	if(gConfig.editor.editorFretboard[0])
	{
		gGame.pTrack->LoadFretboard(gConfig.editor.editorFretboard);
		gGame.pTrack2->LoadFretboard(gConfig.editor.editorFretboard);
	}
	else
	{
		int image = MFRand()%10;
		MFFindData fd;
		MFFind *pFind = MFFileSystem_FindFirst("theme:Fretboards/*", &fd);
		if(pFind)
		{
			bool more = true;
			while(fd.pFilename[0] == '.' && more)
				more = MFFileSystem_FindNext(pFind, &fd);
			if(!more)
			{
				MFFileSystem_FindClose(pFind);
				pFind = NULL;
			}
		}
		if(pFind)
		{
			while(image--)
			{
				if(!MFFileSystem_FindNext(pFind, &fd))
				{
					MFFileSystem_FindClose(pFind);
					pFind = MFFileSystem_FindFirst("theme:Fretboards/*", &fd);
					while(fd.pFilename[0] == '.')
						MFFileSystem_FindNext(pFind, &fd);
				}
			}

			const char *pFilename = MFStr_GetFileNameWithoutExtension(fd.pFilename);
			gGame.pTrack->LoadFretboard(pFilename);
			gGame.pTrack2->LoadFretboard(pFilename);
		}
	}

	eventSuggestions.LoadEventSuggestions("game:events.txt");

	gGame.Push();
	gEdit.Push();
	gpHelp->Push();
}