Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void UpdateSound()
- {
- ToggleButtons( false );
- g_sndUpdate->EnableWindow( false );
- g_launcherDir = boost::filesystem::current_path();
- g_pStatus->SetWindowTextW( L"Status: Downloading" );
- boost::filesystem::path location;
- location = g_launcherDir.wstring() + L"\\" + g_soundPackLanguageW + L".zip";
- if ( boost::filesystem::exists( location ) )
- boost::filesystem::remove( location );
- debug_log( "%s %S", g_soundPackLanguage, g_soundPackLanguageW );
- if ( strstr( g_soundPackLanguage, "English" ) )
- {
- downloadFile( SoundURL_EN, location.wstring().c_str() );
- debug_log( "JP%S", SoundURL_EN );
- }
- else
- {
- downloadFile( SoundURL_JP, location.wstring().c_str() );
- debug_log( "JP%S", SoundURL_JP );
- }
- HZIP hz = OpenZip( location.wstring().c_str(), 0 );
- debug_log( "Unzipping:%S", location.wstring().c_str() );
- g_pStatus->SetWindowTextW( L"Status: Extracting" );
- ZIPENTRY ze; GetZipItem( hz, -1, &ze ); int numitems = ze.index;
- // -1 gives overall information about the zipfile
- for ( int zi = 0; zi < numitems; zi++ )
- {
- ZIPENTRY ze; GetZipItem( hz, zi, &ze ); // fetch individual details
- UnzipItem( hz, zi, ze.name ); // e.g. the item's name.
- }
- CloseZip( hz );
- if ( boost::filesystem::exists( location ) )
- boost::filesystem::remove( location );
- if ( boost::filesystem::exists( g_launcherDir.wstring() + L"\\Sound Pack\\" + g_soundPackLanguageW + L"\\" ) )
- boost::filesystem::remove_all( g_launcherDir.wstring() + L"\\Sound Pack\\" + g_soundPackLanguageW + L"\\" );
- if ( !boost::filesystem::exists( g_launcherDir.wstring() + L"\\Sound Pack\\" + g_soundPackLanguageW + L"\\" ) )
- boost::filesystem::create_directory( g_launcherDir.wstring() + L"\\Sound Pack\\" + g_soundPackLanguageW + L"\\" );
- location = g_launcherDir.wstring() + L"\\" + g_soundPackLanguageW + L"\\";
- int idx = 0;
- int maxCount = dirCount( location );
- debug_line;
- g_pProgressBar->SetRange( 0, 420 );
- debug_line;
- boost::filesystem::directory_iterator end_itr;
- for ( boost::filesystem::directory_iterator itr( location ); itr != end_itr; ++itr )
- {
- debug_line;
- if ( !is_directory( itr->status() ) )
- {
- string currentFileName = itr->path().filename().string();
- debug_log( "%s", currentFileName.c_str() );
- if ( boost::filesystem::exists( location.string() + currentFileName ) )
- {
- wchar_t temp[ 256 ];
- wsprintf( temp, L"Status: Moving(%d/%d)", idx, maxCount );
- g_pStatus->SetWindowTextW( temp );
- g_pProgressBar->SetPos( idx );
- idx++;
- boost::filesystem::copy( location.string() + currentFileName, g_launcherDir.string() + "\\Sound Pack\\" + g_soundPackLanguage + "\\" + currentFileName );
- }
- }
- }
- boost::filesystem::remove_all( location );
- g_pStatus->SetWindowTextW( L"Status: Idle" );
- ToggleButtons( true );
- CheckButtonState();
- g_pProgressBar->SetPos( 0 );
- if ( strstr( g_soundPackLanguage, "English" ) )
- {
- g_localSndDateEN = g_sndDateEN;
- g_Config->Writer->SaveInt( "English Sound Date", g_sndDateEN );
- }
- else
- {
- g_localSndDateJP = g_sndDateJP;
- g_Config->Writer->SaveInt( "Japanese Sound Date", g_sndDateJP );
- }
- ExitThread( 0 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement