void CLibraryFileView::OnLibraryRefreshMetadata()
{
	const DWORD nTotal = GetSelectedCount();

	if ( nTotal == 1 )
	{
		CQuickLock pLock( Library.m_pSection );
		LibraryBuilder.RefreshMetadata( GetSelectedFile()->GetPath() );
		return;
	}

	CProgressDialog dlgProgress( LoadString( ID_LIBRARY_REFRESH_METADATA ) + _T("...") );

	CQuickLock pLock( Library.m_pSection );

	DWORD nCompleted = 0;
	POSITION posSel = StartSelectedFileLoop();
	while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
	{
		CString strPath = pFile->GetPath();

		dlgProgress.Progress( strPath, nCompleted++, nTotal );

		LibraryBuilder.RefreshMetadata( strPath );
	}
}
Exemplo n.º 2
0
int WINAPI SevenZip(const HWND _hwnd, LPCSTR _szCmdLine, LPSTR _szOutput, const DWORD _dwSize)
{
	if (g_StdOut.GetThread())
		return g_StdOut.SetLastError(ERROR_ALREADY_RUNNING);

	CSplitCmdLine scl;
	if (!scl.Split(_szCmdLine))
		return g_StdOut.SetLastError(ERROR_COMMAND_NAME);

	NWindows::NFile::NDir::CTempFile sfxFile;
	if (scl.m_bSfx && scl.IsUpdateCommands())
	{
		CSfxDialog dlgSfx(_hwnd);
		if (dlgSfx.DoModal() == IDCANCEL)
			return g_StdOut.SetLastError(ERROR_USER_CANCEL);

		UInt32 sfxSize, processedSize;
		NWindows::NFile::NIO::COutFile file;
		sfxFile.CreateRandomInTempFolder(FTEXT("sfx"), &file);
		g_StdOut.SetSfxPath(sfxFile.GetPath());
		LPVOID lpResource = CSfxDialog::LoadSfxResource(sfxSize);
		file.Write(lpResource, sfxSize, processedSize);
		AString utf8String;
		ConvertUnicodeToUTF8(dlgSfx.GetConfigText(), utf8String);
		file.Write((const char*)utf8String, utf8String.Len(), processedSize);
		file.Close();
	}

	g_StdOut.SetCommandLine(scl);
	UString strCurrentDirectory;
	if (scl.m_lpBaseDirectory)
	{
		::NWindows::NFile::NDir::GetCurrentDir(strCurrentDirectory);
		if (::NWindows::NFile::NDir::SetCurrentDir(::MultiByteToUnicodeString(scl.m_lpBaseDirectory, scl.m_codePage)) == false)
		{
			g_StdOut << "Base directory isn't found.";
			g_StdOut.CopyBuf(_szOutput, _dwSize);
			g_StdOut.ReSet();
			return g_StdOut.SetLastError(ERROR_COMMAND_NAME);
		}
	}

	g_StdOut.CreateMainThread();

	CProgressDialog dlgProgress(_hwnd);
	g_StdOut.SetProgressDialog(&dlgProgress);
	dlgProgress.SetShowDialog(!scl.m_bHide);
	dlgProgress.SetProgressMode(scl.m_argv[0][0]);
	dlgProgress.CreateModal();

	DWORD dwThreadId;
	::WaitForSingleObject(g_StdOut.GetThread(), INFINITE);
	::GetExitCodeThread(g_StdOut.GetThread(), &dwThreadId);
	::CloseHandle(g_StdOut.GetThread());
	g_StdOut.CopyBuf(_szOutput, _dwSize);
	g_StdOut.ReSet();
	g_CodePage = -1;
	if (scl.m_lpBaseDirectory)
		::NWindows::NFile::NDir::SetCurrentDir(strCurrentDirectory);
    return dwThreadId;
}