// PatchMaker.cpp: implementation of the CPatchMaker class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "NeoPatchMaker.h" #include "PatchMaker.h" #include "Crc32Static.h" #include "afxinet.h" #include "set" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////////// // CPatchMaker::CPatchMaker() { m_PatchmakerState = PMS_IDLE; } CPatchMaker::~CPatchMaker() { } bool CPatchMaker::Go( CEdit* pEditOutput ) { ////////////////////////////////////////////////////////////////////////// // º¯¼ö ÃʱâÈ­ m_ZipArc.Close(); m_arrIndexToUpdateLocalFile.RemoveAll(); m_LocalPatchInfo.Reset(); m_ServerPatchInfo.Reset(); m_strCurrentNewPackageFileName = ""; m_astrFileNameWithSubDirExclusionList.RemoveAll(); m_astrFileNameExclusionList.RemoveAll(); m_astrSubDirExclusionList.RemoveAll(); m_ZipArc.SetCaseSensitivity( false ); ////////////////////////////////////////////////////////////////////////// // ÃʱⰪ ¼³Á¤(Test only) // m_dwPackageMaxSize = 500 * 1024; // 500kbytes, 0.5MB // // m_strPackageFilePath = "F:\\FilePatchTest\\"; // m_strLocalFilePath = "F:\\RYL\\Risk Your Life (Test Server Version)\\"; // m_strDestFilePath = "F:\\FilePatchTest\\modified\\"; // m_SourceType = FILE_ON_LOCAL; // m_DestType = FILE_ON_LOCAL; // m_dwUpdateVersion = 352; // // m_strFTPServerAddr = "211.233.42.245"; // m_strFTPAccount = "ryl"; // m_strFTPPassword = "fldjzk!$"; ////////////////////////////////////////////////////////////////////////// // validity check (path seperator, FTP connectivity) pEditOutput->SetWindowText( "0. Check validity" ); if( false == CheckValidity( pEditOutput ) ) { pEditOutput->SetWindowText( "Faild (Check validity)" ); return false; } ////////////////////////////////////////////////////////////////////////// // server patch info ÀоîµéÀÓ m_PatchmakerState = PMS_LOAD_SERVER_PATCHINFO_LIST; pEditOutput->SetWindowText( "1. Loading previous version patchinfo list" ); if( false == LoadServerPatchInfoList() ) { pEditOutput->SetWindowText( "Faild (Loading previous version patchinfo list)" ); m_PatchmakerState = PMS_IDLE; return false; } ////////////////////////////////////////////////////////////////////////// // local patch info ÀÛ¼º m_PatchmakerState = PMS_BUILD_LOCAL_PATCHINFO_LIST; pEditOutput->SetWindowText( "2. Building local patchinfo list" ); if( false == BuildLocalPatchInfoList() ) { pEditOutput->SetWindowText( "Faild (Building local patchinfo list)" ); m_PatchmakerState = PMS_IDLE; return false; } ////////////////////////////////////////////////////////////////////////// // ±âÁ¸ ÆÐŰÁö ³» ÆÄÀÏ Áß ¾÷µ¥ÀÌÆ® ÇÒ ÆÄÀÏ & »õ·Î ÆÐŰÁöÈ­µÇ¾î¾ß ÇÒ ÆÄÀÏ ¸ñ·Ï ÀÛ¼º m_PatchmakerState = PMS_COLLECT_UPDATE_FILE_LIST; pEditOutput->SetWindowText( "3. Compare & collecting update file list" ); if( false == CollectUpdateFileList() ) { pEditOutput->SetWindowText( "Faild (Compare & collecting update file list)" ); m_PatchmakerState = PMS_IDLE; return false; } ////////////////////////////////////////////////////////////////////////// // ÆÐŰÁö ÆÄÀÏ ¾÷µ¥ÀÌÆ® & ½Å±Ô ÆÐŰÁö ÀÛ¼º m_PatchmakerState = PMS_UPDATE_PACKAGE; pEditOutput->SetWindowText( "4. Updating & creating package(.zip) file" ); if( false == UpdatePackage() ) { pEditOutput->SetWindowText( "Faild (Updating & creating package(.zip) file)" ); m_PatchmakerState = PMS_IDLE; return false; } ////////////////////////////////////////////////////////////////////////// // PatchInfo ÆÄÀÏ ÀúÀå&¾ÐÃà m_PatchmakerState = PMS_UPDATE_PATCHINFO; pEditOutput->SetWindowText( "5. Updating patchinfo file" ); if( false == UpdatePatchInfo() ) { pEditOutput->SetWindowText( "Faild (Updating patchinfo file)" ); m_PatchmakerState = PMS_IDLE; return false; } ////////////////////////////////////////////////////////////////////////// // Clear pEditOutput->SetWindowText( "-- Finished --" ); return true; } ////////////////////////////////////////////////////////////////////////// // validity check (path seperator, FTP connectivity) bool CPatchMaker::CheckValidity( CEdit* pEditOutput ) { // ÀÌÀü¹öÀü ÆÐŰÁö µð·ºÅ丮¸í ³¡ÀÇ seperator È®ÀÎ if( m_strPackageFilePath.GetLength() ) { if( FILE_ON_FTP == m_SourceType ) { if( m_strPackageFilePath.Right(1) != "/" ) { m_strPackageFilePath += "/"; } } if( FILE_ON_LOCAL == m_SourceType ) { if( m_strPackageFilePath.Right(1) != "\\" ) { m_strPackageFilePath += "\\"; } } } else { return false; } if( m_strLocalFilePath.GetLength() ) { if( m_strLocalFilePath.Right(1) != "\\" ) { m_strLocalFilePath += "\\"; } } else { return false; } if( m_strDestFilePath.GetLength() ) { if( FILE_ON_FTP == m_DestType ) { if( m_strDestFilePath.Right(1) != "/" ) { m_strDestFilePath += "/"; } } if( FILE_ON_LOCAL == m_DestType ) { if( m_strDestFilePath.Right(1) != "\\" ) { m_strDestFilePath += "\\"; } } } else { return false; } BOOL bFTPSettingOK = TRUE; if( FILE_ON_FTP == m_SourceType ) { CInternetSession isess; CFtpConnection* pFtp = isess.GetFtpConnection( m_strFTPServerAddr, m_strFTPAccount, m_strFTPPassword, m_nFTPPort, m_bPassiveMode ); bFTPSettingOK = pFtp->SetCurrentDirectory( m_strPackageFilePath ); pFtp->Close(); isess.Close(); } if( FALSE == bFTPSettingOK ) { return false; } return true; } ////////////////////////////////////////////////////////////////////////// // server patch info ÀоîµéÀÓ bool CPatchMaker::LoadServerPatchInfoList() { switch( m_SourceType ) { case FILE_NONE: return true; break; case FILE_ON_FTP: { CInternetSession isess; CFtpConnection* pFtp = isess.GetFtpConnection( m_strFTPServerAddr, m_strFTPAccount, m_strFTPPassword, m_nFTPPort, m_bPassiveMode); pFtp->SetCurrentDirectory( m_strPackageFilePath ); pFtp->GetFile( "PatchInfoV2.zip", m_strDestFilePath+"PatchInfoV2.zip" ); pFtp->Close(); isess.Close(); } break; case FILE_ON_LOCAL: CopyFile( m_strPackageFilePath+"PatchInfoV2.zip", m_strDestFilePath+"PatchInfoV2.zip", FALSE ); break; } // PatchInfo ¾ÐÃàÇØÁ¦ÈÄ ¾ÐÃàÆÄÀÏ »èÁ¦ CZipArchive zipArc; zipArc.Open( m_strDestFilePath+"PatchInfoV2.zip", CZipArchive::zipOpen ); zipArc.ExtractFile( 0, m_strDestFilePath, false, "PatchInfoV2" ); zipArc.Close(); DeleteFile( m_strDestFilePath+"PatchInfoV2.zip" ); // PatchInfo ·Îµå m_ServerPatchInfo.Reset(); m_ServerPatchInfo.Load( m_strDestFilePath+"PatchInfoV2" ); DeleteFile( m_strDestFilePath+"PatchInfoV2"); // filename-to-index map »ý¼º for( size_t i = 0; i < m_ServerPatchInfo.GetList().size(); ++i ) { long lTmp = m_mapFileName2ServerListIndex.size(); m_mapFileName2ServerListIndex[ m_ServerPatchInfo.GetList()[i].szFileName ] = lTmp; } return true; } ////////////////////////////////////////////////////////////////////////// // local patch info ÀÛ¼º bool CPatchMaker::BuildLocalPatchInfoList() { WIN32_FIND_DATA w32fd; HANDLE hFind = FindFirstFile( m_strLocalFilePath+"*.*", &w32fd ); if( INVALID_HANDLE_VALUE == hFind ) { return false; } CString strCurrentSubPath(""); CStringArray astrSubDirList; while( 1 ) { if( !IsExcludedFileWithSubDir(strCurrentSubPath+w32fd.cFileName) && !IsExcludedFile( w32fd.cFileName ) ) { if( w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { CString strTmp; strTmp.Format( "%s%s", strCurrentSubPath, w32fd.cFileName ); if( !IsExcludedSubDir( strTmp ) ) { astrSubDirList.Add( strTmp ); } } else { FilePatchInfoRecord fpir; strcpy( fpir.szFileName, strCurrentSubPath+w32fd.cFileName ); CString strFullPathName = m_strLocalFilePath+strCurrentSubPath+w32fd.cFileName; m_strStateInfoString.Format( "»õ ¹öÀüÀÇ %s ÆÄÀÏÀ» °Ë»çÁß", strFullPathName ); CCrc32Static::FileCrc32Assembly( strFullPathName, fpir.dwCRC32 ); HANDLE hFile = CreateFile( strFullPathName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 ); fpir.dwSize = GetFileSize ( hFile, NULL ); CloseHandle( hFile ); m_LocalPatchInfo.GetList().push_back( fpir ); //m_mapFileName2LocalListIndex[fpir.szFileName] = m_LocalPatchInfo.GetList().size() - 1; } } if( 0 == FindNextFile( hFind, &w32fd ) ) { FindClose( hFind ); // sub dir queue ¿¡ ¼ø¼­¸¦ ±â´Ù¸®°í ÀÖ´Â ³ðÀÌ Á¸ÀçÇϸé if( astrSubDirList.GetSize() > 0 ) { // ²¨³»¼­ ¾²°í strCurrentSubPath = astrSubDirList[0] + "\\"; astrSubDirList.RemoveAt(0); hFind = FindFirstFile( m_strLocalFilePath+strCurrentSubPath+"*.*", &w32fd ); } else { // ¾øÀ½ ·çÇÁ Á¾·á break; } } } return true; } ////////////////////////////////////////////////////////////////////////// // ±âÁ¸ ÆÐŰÁö ³» ÆÄÀÏ Áß ¾÷µ¥ÀÌÆ® ÇÒ ÆÄÀÏ & »õ·Î ÆÐŰÁöÈ­µÇ¾î¾ß ÇÒ ÆÄÀÏ ¸ñ·Ï ÀÛ¼º bool CPatchMaker::CollectUpdateFileList() { size_t i = 0, max = m_LocalPatchInfo.GetList().size(); for( i = 0; i < max; ++i ) { FilePatchInfoRecord &rLocalItem = m_LocalPatchInfo.GetList()[i]; // bool bFound = false; // for( j = 0; j < m_ServerPatchInfo.GetList().size(); ++j ) // { // FilePatchInfoRecord &rServerItem = m_ServerPatchInfo.GetList()[j]; // // // ±âÁ¸ ÆÐŰÁö¿¡ Á¸ÀçÇÏ´Â ÆÄÀÏÀÏ °æ¿ì(·ÎÄà ÆÄÀÏÀÌ ¼­¹ö ¸®½ºÆ®¿¡¼­ ¹ß°ßµÈ °æ¿ì) // if( 0 == stricmp( rLocalItem.szFileName, rServerItem.szFileName ) ) // { // bFound = true; // strcpy( rLocalItem.szPackageFileName, rServerItem.szPackageFileName ); // // // size¿Í CRC32 Ã¼Å©ÇØ ´Ù¸£¸é ¾÷µ¥ÀÌÆ® ´ë»ó¿¡ µî·Ï // if( rLocalItem.dwCRC32 != rServerItem.dwCRC32 || // rLocalItem.dwSize != rServerItem.dwSize ) // { // m_arrIndexToUpdateLocalFile.Add( i ); // // rLocalItem.dwVersion = m_dwUpdateVersion; // } // else // { // rLocalItem.dwVersion = rServerItem.dwVersion; // } // // break; // } // // } // // // ±âÁ¸ ÆÐŰÁö¿¡ Á¸ÀçÇÏÁö ¾Ê´Â ÆÄÀÏ // if( false == bFound ) // { // m_arrIndexToUpdateLocalFile.Add( i ); // // rLocalItem.dwVersion = m_dwUpdateVersion; // } std::map< PTR_STRING, int, PTR_STRING_LESS >::iterator it; it = m_mapFileName2ServerListIndex.find( rLocalItem.szFileName ); if( m_mapFileName2ServerListIndex.end() == it ) { // ±âÁ¸ ÆÐŰÁö¿¡ Á¸ÀçÇÏÁö ¾Ê´Â ÆÄÀÏ m_arrIndexToUpdateLocalFile.Add( i ); rLocalItem.dwVersion = m_dwUpdateVersion; } else { long lIdx = it->second; FilePatchInfoRecord &rServerItem = m_ServerPatchInfo.GetList()[it->second]; strcpy( rLocalItem.szPackageFileName, rServerItem.szPackageFileName ); // size¿Í CRC32 Ã¼Å©ÇØ ´Ù¸£¸é ¾÷µ¥ÀÌÆ® ´ë»ó¿¡ µî·Ï if( rLocalItem.dwCRC32 != rServerItem.dwCRC32 || rLocalItem.dwSize != rServerItem.dwSize ) { m_arrIndexToUpdateLocalFile.Add( i ); rLocalItem.dwVersion = m_dwUpdateVersion; } else { rLocalItem.dwVersion = rServerItem.dwVersion; } } } return true; } ////////////////////////////////////////////////////////////////////////// // ÆÐŰÁö ÆÄÀÏ ¾÷µ¥ÀÌÆ® & ½Å±Ô ÆÐŰÁö ÀÛ¼º bool CPatchMaker::UpdatePackage() { int i; std::set setUpdatePackageFileList; for( i = 0; i < m_arrIndexToUpdateLocalFile.GetSize(); ++i ) { FilePatchInfoRecord &rFpir = m_LocalPatchInfo.GetList()[ m_arrIndexToUpdateLocalFile[i] ]; if( '\0' != rFpir.szPackageFileName[0] ) // ÆÐŰÁö ÆÄÀÏ À̸§ÀÌ ºó ¹®ÀÚ¿­ÀÌ ¾Æ´Ò °æ¿ì(ÀÌ¹Ì ÆÐŰÁö¿¡ µé¾î°¡ ÀÖ´Â ÆÄÀÏ) { // ¹Þ¾Æ¿Ã ÆÐŰÁö ÆÄÀÏ ¸ñ·Ï¿¡ ÀÌ¹Ì µî·ÏµÇ¾îÀÖ´ÂÁö È®ÀÎ(¾øÀ¸¸é Ãß°¡) setUpdatePackageFileList.insert( CString(rFpir.szPackageFileName) ); } } // ÆÐŰÁö ÆÄÀÏ º¹»ç(ȤÀº ´Ù¿î·Îµå) std::set::iterator it; switch( m_SourceType ) { case FILE_ON_LOCAL: { // copy packages from src to dest for(it = setUpdatePackageFileList.begin(); it != setUpdatePackageFileList.end(); ++it ) { CString &rstr = *it; CopyFile( m_strPackageFilePath+(*it)+".zip", m_strDestFilePath+(*it)+".zip", FALSE ); } } break; case FILE_ON_FTP: { CInternetSession isess; CFtpConnection* pFtp = isess.GetFtpConnection( m_strFTPServerAddr, m_strFTPAccount, m_strFTPPassword, m_nFTPPort, m_bPassiveMode ); pFtp->SetCurrentDirectory( m_strPackageFilePath ); for(it = setUpdatePackageFileList.begin(); it != setUpdatePackageFileList.end(); ++it ) { pFtp->GetFile( (*it)+".zip", m_strDestFilePath+(*it)+".zip" ); Sleep(1); } pFtp->Close(); isess.Close(); } break; } // package update, ȤÀº ½Å±Ô package ÀÛ¼º for( i = 0; i < m_arrIndexToUpdateLocalFile.GetSize(); ++i ) { Sleep(1); FilePatchInfoRecord &rFpir = m_LocalPatchInfo.GetList()[ m_arrIndexToUpdateLocalFile[i] ]; if( '\0' == rFpir.szPackageFileName[0] ) { // ÆÄÀÏÀÇ ÆÐŰÁö À̸§ Çʵ尡 ºñ¾î ÀÖÀ¸¸é -> ½Å±Ô or ¸¶Áö¸· ÆÐŰÁö¿¡ Ãß°¡ // // ÁÖÀÇ : ÆÐŰÁö À̸§ Çʵ尡 ºñ¾î ÀÖ´Ù°í ÇØ¼­ Ç×»ó ½Å±Ô ÆÐŰÁö¸¦ ¸¸µå´Â°Ô ¾Æ´Ï´Ù. // ÃÖ±Ù¿¡ ¸¸µç ½Å±Ô ÆÐŰÁö°¡ ´Ù ä¿öÁöÁö ¾Ê¾ÒÀ¸¸é °Å±â¿¡ µé¾î°¡´Â °ÍÀÓ if( m_strCurrentNewPackageFileName == "" ) { // ÆÐŰÁö ÆÄÀÏÀ» ½Å±Ô·Î ¸¸µé°Å³ª m_strCurrentNewPackageFileName = GetNextPackageFileName(); m_ZipArc.Open( m_strDestFilePath+m_strCurrentNewPackageFileName+".zip", CZipArchive::zipCreate ); } else { // granular ¿ë·®ÀÌ ´Ù ä¿öÁöÁö¾ÊÀº ÆÐŰÁö°¡ ¸¶Áö¸·ÀÏ °æ¿ì ±×°ÍÀ» ¿ÀÇ m_ZipArc.Open( m_strDestFilePath+m_strCurrentNewPackageFileName+".zip", CZipArchive::zipOpen ); } m_ZipArc.SetRootPath( m_strLocalFilePath ); CZipAddNewFileInfo zanfi( m_strLocalFilePath+rFpir.szFileName, false ); zanfi.Defaults(); m_ZipArc.AddNewFile( zanfi ); m_ZipArc.Close(); // patchinfo ¿¡ ±â·ÏµÉ ÆÐŰÁö À̸§ ÇÊµå ¾÷µ¥ÀÌÆ® strcpy( rFpir.szPackageFileName, m_strCurrentNewPackageFileName ); DWORD dwPackageSize = GetFileSize( m_strDestFilePath+m_strCurrentNewPackageFileName+".zip" ); // ÆÐŰÁö ÃÖ´ë »çÀÌÁ ³Ñ¾î°¬À» °æ¿ì or ´Üµ¶ÆÐŰÁöÈ­ ÇØ¾ß ÇÒ ÆÄÀÏ(Client.exe °°Àº) ÀÏ °æ¿ì bool bSoleFile = IsSoleFileWithSubDir( rFpir.szFileName ); if( dwPackageSize > m_dwPackageMaxSize || bSoleFile ) { m_ZipArc.Open( m_strDestFilePath+m_strCurrentNewPackageFileName+".zip", CZipArchive::zipOpen ); if( 1 == m_ZipArc.GetCount( true ) ) { // ÆÄÀÏÀÌ Çϳª»ÓÀϰæ¿ì ¾î¿¼ö ¾øÀ¸¹Ç·Î ÆÐ½º m_ZipArc.Close(); } else { // ÆÄÀÏÀÌ ¿©·¯°³ÀÏ °æ¿ì, ¸¶Áö¸·À¸·Î Ãß°¡µÈ ÆÄÀÏ »èÁ¦ int nIdx = m_ZipArc.FindFile( rFpir.szFileName, CZipArchive::ffCaseSens, false ); m_ZipArc.DeleteFile( nIdx ); m_ZipArc.Close(); // ...ÇÑ ´ÙÀ½, ´ÙÀ½ ÆÐŰÁö ÆÄÀÏÀ» »ý¼ºÇØ °Å±â¿¡ ³À´Ù Ãß°¡ m_strCurrentNewPackageFileName = GetNextPackageFileName(); m_ZipArc.Open( m_strDestFilePath+m_strCurrentNewPackageFileName+".zip", CZipArchive::zipCreate ); m_ZipArc.SetRootPath( m_strLocalFilePath ); CZipAddNewFileInfo zanfi( m_strLocalFilePath+rFpir.szFileName, false ); zanfi.Defaults(); m_ZipArc.AddNewFile( zanfi ); m_ZipArc.Close(); // patchinfo ¿¡ ±â·ÏµÉ ÆÐŰÁö À̸§ ÇÊµå ¾÷µ¥ÀÌÆ® strcpy( rFpir.szPackageFileName, m_strCurrentNewPackageFileName ); } // ´Üµ¶ÆÐŰÁöÈ­ ÇØ¾ß ÇÒ ÆÄÀÏÀÇ °æ¿ì ÀÌÈÄ¿¡ Ãß°¡µÇ´Â ÆÄÀÏÀÌ ¾ø¾î¾ßÇÑ´Ù. // (currentÆÐŰÁö À̸§À» ºñ¿ò -> ´ÙÀ½ ÅÏ¿¡ »õ ÆÄÀÏÀ» ¸¸µé°ÔµÊ) if( bSoleFile ) { /* m_strCurrentNewPackageFileName = GetNextPackageFileName(); m_ZipArc.Open( m_strDestFilePath+m_strCurrentNewPackageFileName+".zip", CZipArchive::zipCreate ); m_ZipArc.SetRootPath( m_strLocalFilePath ); m_ZipArc.Close(); */ m_strCurrentNewPackageFileName = ""; } } //strcpy( rFpir.szPackageFileName, m_strCurrentNewPackageFileName ); } else { // ±âÁ¸ÆÐŰÁö ¾÷µ¥ÀÌÆ®(replace file) m_ZipArc.Open( m_strDestFilePath+rFpir.szPackageFileName+".zip", CZipArchive::zipOpen ); int nIdx = m_ZipArc.FindFile( rFpir.szFileName, CZipArchive::ffCaseSens, false ); if( -1 == nIdx ) { CString strErr; strErr.Format( "%s ÆÐŰÁö ÆÄÀÏ ³»¿¡ %s ÆÄÀÏÀÌ Á¸ÀçÇÏÁö ¾Ê±¸¸¶ÀÌ", rFpir.szPackageFileName, rFpir.szFileName ); AfxMessageBox( strErr ); } else { m_ZipArc.DeleteFile( nIdx ); } m_ZipArc.SetRootPath( m_strLocalFilePath ); CZipAddNewFileInfo zanfi( m_strLocalFilePath+rFpir.szFileName, false ); zanfi.Defaults(); m_ZipArc.AddNewFile( zanfi ); m_ZipArc.Close( CZipArchive::afNoException, true ); } } return true; } ////////////////////////////////////////////////////////////////////////// // PatchInfo ÆÄÀÏ ÀúÀå&¾ÐÃà bool CPatchMaker::UpdatePatchInfo() { // PatchInfo ÀúÀå m_LocalPatchInfo.SetVersion( m_dwUpdateVersion ); m_LocalPatchInfo.Save( m_strDestFilePath+"PatchInfoV2" ); // PatchInfo ¾ÐÃàÈÄ ¿øº»ÆÄÀÏ »èÁ¦ CZipArchive zipArc; zipArc.Open( m_strDestFilePath+"PatchInfoV2.zip", CZipArchive::zipCreate ); zipArc.AddNewFile( m_strDestFilePath+"PatchInfoV2", "PatchInfoV2" ); zipArc.Close(); DeleteFile( m_strDestFilePath+"PatchInfoV2"); // CInternetSession isess; // CFtpConnection* pFtp = isess.GetFtpConnection( "211.233.42.245", "ryl", "fldjzk!$", 21, m_bPassiveMode ); // pFtp->SetCurrentDirectory( m_strPackageFilePath ); // pFtp->GetFile( "PatchInfo.zip", m_strDestFilePath+"PatchInfo.zip" ); // pFtp->Close(); // isess.Close(); return true; } ////////////////////////////////////////////////////////////////////////// // // »õ ÆÐŰÁö ÆÄÀÏ À̸§ »ý¼º // (ÆÄÀÏ À̸§ Áß È®ÀåÀÚ Á¦¿Ü) const char* CPatchMaker::GetNextPackageFileName() { static char szBuff[MAX_PACKAGE_FILE_NAME_LENGTH*2]; CTime t = CTime::GetCurrentTime(); CString strHeader = t.Format( "%Y%m%d_%H%M_" ); int n = 0; char szTmp[4]; while( n < 1000 ) { sprintf( szTmp, "%03d", n ); CString strFileName = m_strDestFilePath + strHeader + szTmp + ".zip"; // if( 0xFFFFFFFF == GetFileAttributes( strFileName ) ) // { // if( ERROR_FILE_NOT_FOUND == GetLastError() ) // { // strcpy( szBuff, strHeader+szTmp ); // break; // } // } if( !IsFileExist( strFileName ) ) { strcpy( szBuff, strHeader+szTmp ); break; } ++n; } if( 1000 == n ) { return NULL; } return szBuff; } bool CPatchMaker::IsExcludedFile( const char* szFileName ) { for( int i = 0; i < m_astrFileNameExclusionList.GetSize(); ++i ) { if( 0 == stricmp( szFileName, m_astrFileNameExclusionList[i] ) ) { return true; } } // hard-coded exclusion list if( 0 == stricmp( szFileName, "." ) ) return true; if( 0 == stricmp( szFileName, ".." ) ) return true; if( 0 == stricmp( szFileName, "vssver.scc" ) ) return true; return false; } bool CPatchMaker::IsExcludedFileWithSubDir( const char* szFileNameWithSubDir ) { for( int i = 0; i < m_astrFileNameWithSubDirExclusionList.GetSize(); ++i ) { if( 0 == stricmp( szFileNameWithSubDir, m_astrFileNameWithSubDirExclusionList[i] ) ) { return true; } } // hard-coded exclusion list if( 0 == stricmp( szFileNameWithSubDir, "mp.ini" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "RenderOption.dat" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "ClientOption.dat" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "Patchinfo.pat" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "UpdateFileList.txt" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "VersionInfo.dat" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "Login.dat" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "LoginRes.dll" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "Patchinfo.cache" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "Patchinfo.local" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "LC2.OGG" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "Z3D_SetupDirectX.exe" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "DirectXInstaller.exe" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "FileChecker.exe" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "DSETUP.dll" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "dsetup32.dll" ) ) return true; return false; } bool CPatchMaker::IsExcludedSubDir( const char* szSubDir ) { for( int i = 0; i < m_astrSubDirExclusionList.GetSize(); ++i ) { if( 0 == stricmp( szSubDir, m_astrSubDirExclusionList[i] ) ) { return true; } } // hard-coded exclusion list //if( 0 == stricmp( szSubDir, "GameGuard" ) ) return true; if( !m_bCheckNoticeFolder && 0 == stricmp( szSubDir, "Notice" ) ) return true; //if( 0 == stricmp( szSubDir, "update" ) ) return true; if( 0 == stricmp( szSubDir, "DirectX" ) ) return true; return false; } // ´ÜÀÏ ÆÐŰÁö·Î ¸¸µé¾î¾ß ÇÏ´Â ÆÄÀÏÀΰ¡? bool CPatchMaker::IsSoleFileWithSubDir( const char* szFileNameWithSubDir ) { // for( int i = 0; i < m_astrSubDirSoleFileList.GetSize(); ++i ) // { // if( 0 == stricmp( szSubDir, m_astrSubDirSoleFileList[i] ) ) // { // return true; // } // } // hard-coded sole file list if( 0 == stricmp( szFileNameWithSubDir, "Client.exe" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "Login.new" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "ItemScript.gsf" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "MonsterProtoType.gsf" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "script1.gsf" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "SkillScript.gsf" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "npcscript.mcf" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "quest.mcf" ) ) return true; if( 0 == stricmp( szFileNameWithSubDir, "Script.mcf" ) ) return true; // if( 0 == stricmp( szSubDir, "" ) ) return true; return false; } int CPatchMaker::GetPatchInfoVersion() { if( false == LoadServerPatchInfoList() ) { return -1; } return (int)m_ServerPatchInfo.GetVersion(); }