#include "stdafx.h" #define ROOT_SECTOR L"\"Sounds\"" #define JOIN_SECTOR L"\"Connect\"" #define T_SECTOR L"\"T Win\"" #define CT_SECTOR L"\"CT Win\"" std::vector< std::wstring > g_vTSounds, g_vCTSounds, g_vJoinSounds; void ReadFiles( TCHAR* szDataPath, std::vector< std::wstring > *vBuff ) { WIN32_FIND_DATA fData; HANDLE l_hFile = FindFirstFile(szDataPath, &fData); do { if( _tcscmp(fData.cFileName, L".mp3") ) { vBuff->push_back(fData.cFileName); } } while ( FindNextFile(l_hFile, &fData) ); FindClose(l_hFile); } void AddSector(TCHAR* szMainSector, TCHAR* szSectorName, std::vector< std::wstring > vBuff) { DWORD l_dwPageCounter = 0; WCHAR l_szCounterBuff[36]; _itow_s(++l_dwPageCounter, l_szCounterBuff, 10); _tcscat(szMainSector, L"\t"); _tcscat(szMainSector, JOIN_SECTOR); _tcscat(szMainSector, L"\n{\n"); for(std::vector< std::wstring >::iterator i = vBuff.begin(); i != vBuff.end(); i++) { _tcscat(szMainSector, L"\t\""); _tcscat(szMainSector, l_szCounterBuff); _tcscat(szMainSector, L"\"\n{\n\t\t"); _tcscat(szMainSector, L"\"sound\"\t\""); _tcscat(szMainSector, i->c_str()); _tcscat(szMainSector, L"\"\n\t\t}\n"); } } int _tmain(int argc, _TCHAR* argv[]) { TCHAR l_szDataPath[1024], l_szCTDataPath[1024], l_szTDataPath[1024]; GetCurrentDirectory(sizeof(l_szDataPath), l_szDataPath); _tcscpy(l_szCTDataPath, l_szDataPath); _tcscpy(l_szTDataPath, l_szDataPath); _tcscat(l_szCTDataPath, L"\\ct\\*"); _tcscat(l_szTDataPath, L"\\t\\*"); _tcscat(l_szDataPath, L"\\*"); ReadFiles(l_szDataPath, &g_vJoinSounds); ReadFiles(l_szTDataPath, &g_vTSounds); ReadFiles(l_szCTDataPath, &g_vCTSounds); TCHAR l_szBlock[4096]; WCHAR l_szCounterBuff[36]; DWORD l_dwPageCounter = 0; HANDLE l_hConfig = CreateFile( L"qsounds.cfg", GENERIC_ALL, 0, 0, CREATE_ALWAYS, 0, 0); _tcscpy(l_szBlock, ROOT_SECTOR); _tcscat(l_szBlock, L"\n{\n"); AddSector(l_szBlock, JOIN_SECTOR, g_vJoinSounds); AddSector(l_szBlock, T_SECTOR, g_vTSounds); AddSector(l_szBlock, CT_SECTOR, g_vCTSounds); _tcscat(l_szBlock, L"}"); DWORD l_dwCount; WriteFile(l_hConfig, l_szBlock, sizeof(l_szBlock), &l_dwCount, NULL); CloseHandle(l_hConfig); return 0; }