summaryrefslogtreecommitdiff
path: root/devtools/syncfrommirror
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/syncfrommirror')
-rw-r--r--devtools/syncfrommirror/Redir.cpp358
-rw-r--r--devtools/syncfrommirror/Redir.h60
-rw-r--r--devtools/syncfrommirror/Redirect.cpp152
-rw-r--r--devtools/syncfrommirror/Redirect.h55
-rw-r--r--devtools/syncfrommirror/StdAfx.cpp15
-rw-r--r--devtools/syncfrommirror/StdAfx.h33
-rw-r--r--devtools/syncfrommirror/res/syncfrommirror.icobin0 -> 29926 bytes
-rw-r--r--devtools/syncfrommirror/res/syncfrommirror.rc213
-rw-r--r--devtools/syncfrommirror/resource.h34
-rw-r--r--devtools/syncfrommirror/syncfrommirror.cpp70
-rw-r--r--devtools/syncfrommirror/syncfrommirror.h54
-rw-r--r--devtools/syncfrommirror/syncfrommirror.rc196
-rw-r--r--devtools/syncfrommirror/syncfrommirror.vpc60
-rw-r--r--devtools/syncfrommirror/syncfrommirrorDlg.cpp275
-rw-r--r--devtools/syncfrommirror/syncfrommirrorDlg.h78
15 files changed, 1453 insertions, 0 deletions
diff --git a/devtools/syncfrommirror/Redir.cpp b/devtools/syncfrommirror/Redir.cpp
new file mode 100644
index 0000000..cbb6203
--- /dev/null
+++ b/devtools/syncfrommirror/Redir.cpp
@@ -0,0 +1,358 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+//////////////////////////////////////////////////////////////////////
+//
+// Redirector - to redirect the input / output of a console
+//
+// Developer: Jeff Lee
+// Dec 10, 2001
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "stdafx.h"
+#include "Redir.h"
+
+#ifdef _DEBUG
+#undef THIS_FILE
+static char THIS_FILE[]=__FILE__;
+#define new DEBUG_NEW
+#endif
+
+//#define _TEST_REDIR
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+CRedirector::CRedirector() :
+ m_hStdinWrite(NULL),
+ m_hStdoutRead(NULL),
+ m_hChildProcess(NULL),
+ m_hThread(NULL),
+ m_hEvtStop(NULL),
+ m_dwThreadId(0),
+ m_dwWaitTime(1000)
+{
+}
+
+CRedirector::~CRedirector()
+{
+ Close();
+}
+
+//////////////////////////////////////////////////////////////////////
+// CRedirector implementation
+//////////////////////////////////////////////////////////////////////
+
+BOOL CRedirector::Open(LPCTSTR pszCmdLine, LPCTSTR pszCurrentDirectory)
+{
+ HANDLE hStdoutReadTmp; // parent stdout read handle
+ HANDLE hStdoutWrite, hStderrWrite; // child stdout write handle
+ HANDLE hStdinWriteTmp; // parent stdin write handle
+ HANDLE hStdinRead; // child stdin read handle
+ SECURITY_ATTRIBUTES sa;
+
+ Close();
+ hStdoutReadTmp = NULL;
+ hStdoutWrite = hStderrWrite = NULL;
+ hStdinWriteTmp = NULL;
+ hStdinRead = NULL;
+
+ // Set up the security attributes struct.
+ sa.nLength = sizeof(SECURITY_ATTRIBUTES);
+ sa.lpSecurityDescriptor = NULL;
+ sa.bInheritHandle = TRUE;
+
+ BOOL bOK = FALSE;
+ __try
+ {
+ // Create a child stdout pipe.
+ if (!::CreatePipe(&hStdoutReadTmp, &hStdoutWrite, &sa, 0))
+ __leave;
+
+ // Create a duplicate of the stdout write handle for the std
+ // error write handle. This is necessary in case the child
+ // application closes one of its std output handles.
+ if (!::DuplicateHandle(
+ ::GetCurrentProcess(),
+ hStdoutWrite,
+ ::GetCurrentProcess(),
+ &hStderrWrite,
+ 0, TRUE,
+ DUPLICATE_SAME_ACCESS))
+ __leave;
+
+ // Create a child stdin pipe.
+ if (!::CreatePipe(&hStdinRead, &hStdinWriteTmp, &sa, 0))
+ __leave;
+
+ // Create new stdout read handle and the stdin write handle.
+ // Set the inheritance properties to FALSE. Otherwise, the child
+ // inherits the these handles; resulting in non-closeable
+ // handles to the pipes being created.
+ if (!::DuplicateHandle(
+ ::GetCurrentProcess(),
+ hStdoutReadTmp,
+ ::GetCurrentProcess(),
+ &m_hStdoutRead,
+ 0, FALSE, // make it uninheritable.
+ DUPLICATE_SAME_ACCESS))
+ __leave;
+
+ if (!::DuplicateHandle(
+ ::GetCurrentProcess(),
+ hStdinWriteTmp,
+ ::GetCurrentProcess(),
+ &m_hStdinWrite,
+ 0, FALSE, // make it uninheritable.
+ DUPLICATE_SAME_ACCESS))
+ __leave;
+
+ // Close inheritable copies of the handles we do not want to
+ // be inherited.
+ DestroyHandle(hStdoutReadTmp);
+ DestroyHandle(hStdinWriteTmp);
+
+ // launch the child process
+ if (!LaunchChild(pszCmdLine, pszCurrentDirectory,
+ hStdoutWrite, hStdinRead, hStderrWrite))
+ __leave;
+
+ // Child is launched. Close the parents copy of those pipe
+ // handles that only the child should have open.
+ // Make sure that no handles to the write end of the stdout pipe
+ // are maintained in this process or else the pipe will not
+ // close when the child process exits and ReadFile will hang.
+ DestroyHandle(hStdoutWrite);
+ DestroyHandle(hStdinRead);
+ DestroyHandle(hStderrWrite);
+
+ // Launch a thread to receive output from the child process.
+ m_hEvtStop = ::CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hThread = ::CreateThread(
+ NULL, 0,
+ OutputThread,
+ this,
+ 0,
+ &m_dwThreadId);
+ if (!m_hThread)
+ __leave;
+
+ bOK = TRUE;
+ }
+
+ __finally
+ {
+ if (!bOK)
+ {
+ DWORD dwOsErr = ::GetLastError();
+ char szMsg[40];
+ ::sprintf(szMsg, "Redirect console error: %x\r\n", dwOsErr);
+ WriteStdError(szMsg);
+ DestroyHandle(hStdoutReadTmp);
+ DestroyHandle(hStdoutWrite);
+ DestroyHandle(hStderrWrite);
+ DestroyHandle(hStdinWriteTmp);
+ DestroyHandle(hStdinRead);
+ Close();
+ ::SetLastError(dwOsErr);
+ }
+ }
+
+ return bOK;
+}
+
+void CRedirector::Close()
+{
+ if (m_hThread != NULL)
+ {
+ // this function might be called from redir thread
+ if (::GetCurrentThreadId() != m_dwThreadId)
+ {
+ ASSERT(m_hEvtStop != NULL);
+ ::SetEvent(m_hEvtStop);
+ //::WaitForSingleObject(m_hThread, INFINITE);
+ if (::WaitForSingleObject(m_hThread, 5000) == WAIT_TIMEOUT)
+ {
+ WriteStdError(_T("The redir thread is dead\r\n"));
+ ::TerminateThread(m_hThread, -2);
+ }
+ }
+
+ DestroyHandle(m_hThread);
+ }
+
+ DestroyHandle(m_hEvtStop);
+ DestroyHandle(m_hChildProcess);
+ DestroyHandle(m_hStdinWrite);
+ DestroyHandle(m_hStdoutRead);
+ m_dwThreadId = 0;
+}
+
+// write data to the child's stdin
+BOOL CRedirector::Printf(LPCTSTR pszFormat, ...)
+{
+ if (!m_hStdinWrite)
+ return FALSE;
+
+ CString strInput;
+ va_list argList;
+
+ va_start(argList, pszFormat);
+ strInput.FormatV(pszFormat, argList);
+ va_end(argList);
+
+ DWORD dwWritten;
+ return ::WriteFile(m_hStdinWrite, (LPCTSTR)strInput,
+ strInput.GetLength(), &dwWritten, NULL);
+}
+
+BOOL CRedirector::LaunchChild(LPCTSTR pszCmdLine,
+ LPCTSTR pszCurrentDirectory,
+ HANDLE hStdOut,
+ HANDLE hStdIn,
+ HANDLE hStdErr)
+{
+ PROCESS_INFORMATION pi;
+ STARTUPINFO si;
+
+ ASSERT(::AfxIsValidString(pszCmdLine));
+ ASSERT(m_hChildProcess == NULL);
+
+ // Set up the start up info struct.
+ ::ZeroMemory(&si, sizeof(STARTUPINFO));
+ si.cb = sizeof(STARTUPINFO);
+ si.hStdOutput = hStdOut;
+ si.hStdInput = hStdIn;
+ si.hStdError = hStdErr;
+ si.wShowWindow = SW_HIDE;
+ si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+
+ // Note that dwFlags must include STARTF_USESHOWWINDOW if we
+ // use the wShowWindow flags. This also assumes that the
+ // CreateProcess() call will use CREATE_NEW_CONSOLE.
+
+ // Launch the child process.
+ if (!::CreateProcess(
+ NULL,
+ (LPTSTR)pszCmdLine,
+ NULL, NULL,
+ TRUE,
+ CREATE_NEW_CONSOLE,
+ NULL, pszCurrentDirectory,
+ &si,
+ &pi))
+ return FALSE;
+
+ m_hChildProcess = pi.hProcess;
+ // Close any unuseful handles
+ ::CloseHandle(pi.hThread);
+ return TRUE;
+}
+
+// redirect the child process's stdout:
+// return: 1: no more data, 0: child terminated, -1: os error
+int CRedirector::RedirectStdout()
+{
+ ASSERT(m_hStdoutRead != NULL);
+ for (;;)
+ {
+ DWORD dwAvail = 0;
+ if (!::PeekNamedPipe(m_hStdoutRead, NULL, 0, NULL,
+ &dwAvail, NULL)) // error
+ break;
+
+ if (!dwAvail) // not data available
+ return 1;
+
+ char szOutput[16*1024 + 1];
+ DWORD dwRead = 0;
+ if (!::ReadFile(m_hStdoutRead, szOutput, min(16*1024, dwAvail),
+ &dwRead, NULL) || !dwRead) // error, the child might ended
+ break;
+
+ szOutput[dwRead] = 0;
+ WriteStdOut(szOutput);
+ }
+
+ DWORD dwError = ::GetLastError();
+ if (dwError == ERROR_BROKEN_PIPE || // pipe has been ended
+ dwError == ERROR_NO_DATA) // pipe closing in progress
+ {
+#ifdef _TEST_REDIR
+ WriteStdOut("\r\n<TEST INFO>: Child process ended\r\n");
+#endif
+ return 0; // child process ended
+ }
+
+ WriteStdError("Read stdout pipe error\r\n");
+ return -1; // os error
+}
+
+void CRedirector::DestroyHandle(HANDLE& rhObject)
+{
+ if (rhObject != NULL)
+ {
+ ::CloseHandle(rhObject);
+ rhObject = NULL;
+ }
+}
+
+void CRedirector::WriteStdOut(LPCSTR pszOutput)
+{
+ TRACE("%s", pszOutput);
+}
+
+void CRedirector::WriteStdError(LPCSTR pszError)
+{
+ TRACE("%s", pszError);
+}
+
+// thread to receive output of the child process
+DWORD WINAPI CRedirector::OutputThread(LPVOID lpvThreadParam)
+{
+ HANDLE aHandles[2];
+ int nRet;
+ CRedirector* pRedir = (CRedirector*) lpvThreadParam;
+
+ ASSERT(pRedir != NULL);
+ aHandles[0] = pRedir->m_hChildProcess;
+ aHandles[1] = pRedir->m_hEvtStop;
+ aHandles[2] = pRedir->m_hStdoutRead;
+
+ for (;;)
+ {
+ // redirect stdout till there's no more data.
+ nRet = pRedir->RedirectStdout();
+ if (nRet <= 0)
+ break;
+
+ // check if the child process has terminated.
+ DWORD dwRc = ::WaitForMultipleObjects(
+ 3, aHandles, FALSE, pRedir->m_dwWaitTime);
+ if (WAIT_OBJECT_0 == dwRc || WAIT_FAILED == dwRc ) // the child process ended
+ {
+ nRet = pRedir->RedirectStdout();
+ if (nRet > 0)
+ nRet = 0;
+ break;
+ }
+ if (WAIT_OBJECT_0+1 == dwRc) // m_hEvtStop was signalled
+ {
+ nRet = 1; // cancelled
+ break;
+ }
+
+ // If we don't sleep here, then syncfrommirror will eat lots of CPU looping here.
+ Sleep( 20 );
+ }
+
+ // close handles
+ pRedir->Close();
+ return nRet;
+}
diff --git a/devtools/syncfrommirror/Redir.h b/devtools/syncfrommirror/Redir.h
new file mode 100644
index 0000000..944dff0
--- /dev/null
+++ b/devtools/syncfrommirror/Redir.h
@@ -0,0 +1,60 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+//////////////////////////////////////////////////////////////////////
+//
+// Redirector - to redirect the input / output of a console
+//
+// Developer: Jeff Lee
+// Dec 10, 2001
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(AFX_REDIR_H__4FB57DC3_29A3_11D5_BB60_006097553C52__INCLUDED_)
+#define AFX_REDIR_H__4FB57DC3_29A3_11D5_BB60_006097553C52__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+class CRedirector
+{
+public:
+ CRedirector();
+ virtual ~CRedirector();
+
+protected:
+ HANDLE m_hThread; // thread to receive the output of the child process
+ HANDLE m_hEvtStop; // event to notify the redir thread to exit
+ DWORD m_dwThreadId; // id of the redir thread
+ DWORD m_dwWaitTime; // wait time to check the status of the child process
+
+ HANDLE m_hStdinWrite; // write end of child's stdin pipe
+ HANDLE m_hStdoutRead; // read end of child's stdout pipe
+ HANDLE m_hChildProcess;
+
+ BOOL LaunchChild(LPCTSTR pszCmdLine, LPCTSTR pszCurrentDirectory,
+ HANDLE hStdOut, HANDLE hStdIn, HANDLE hStdErr);
+ int RedirectStdout();
+ void DestroyHandle(HANDLE& rhObject);
+
+ static DWORD WINAPI OutputThread(LPVOID lpvThreadParam);
+
+protected:
+ // overrides:
+ virtual void WriteStdOut(LPCSTR pszOutput);
+ virtual void WriteStdError(LPCSTR pszError);
+
+public:
+ BOOL Open(LPCTSTR pszCmdLine, LPCTSTR pszCurrentDirectory = NULL);
+ virtual void Close();
+ BOOL Printf(PRINTF_FORMAT_STRING LPCTSTR pszFormat, ...);
+
+ void SetWaitTime(DWORD dwWaitTime) { m_dwWaitTime = dwWaitTime; }
+};
+
+#endif // !defined(AFX_REDIR_H__4FB57DC3_29A3_11D5_BB60_006097553C52__INCLUDED_)
diff --git a/devtools/syncfrommirror/Redirect.cpp b/devtools/syncfrommirror/Redirect.cpp
new file mode 100644
index 0000000..15ffa8b
--- /dev/null
+++ b/devtools/syncfrommirror/Redirect.cpp
@@ -0,0 +1,152 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+//------------------------------------------------------------------------------
+// Redirect.cpp : implementation file
+//
+// Creates a child process that runs a user-specified command and redirects its
+// standard output and standard error to a CEdit control.
+//
+// Written by Matt Brunk ([email protected])
+// Copyright (C) 1999 Matt Brunk
+// All rights reserved.
+//
+// This code may be used in compiled form in any way. This file may be
+// distributed by any means providing it is not sold for profit without
+// the written consent of the author, and providing that this notice and the
+// author's name is included in the distribution. If the compiled form of the
+// source code in this file is used in a commercial application, an e-mail to
+// the author would be appreciated.
+//
+// Thanks to Dima Shamroni ([email protected]) for providing the essential
+// code for this class.
+//
+// Thanks to Chris Maunder ([email protected]) for the PeekAndPump()
+// function (from his CProgressWnd class).
+//
+// Initial Release Feb 8, 1999
+//------------------------------------------------------------------------------
+
+
+#include "stdafx.h"
+#include <string.h>
+#include <string>
+#include "Redirect.h"
+
+const int BUF_SIZE = 8192;
+
+CRedirect::~CRedirect()
+{
+}
+
+void CRedirect::Run( LPCTSTR szCommand, CEdit *pEdit, LPCTSTR pszCurrentDirectory )
+{
+ m_pEdit = pEdit;
+ m_bStopped = false;
+
+ if ( !Open( szCommand, pszCurrentDirectory ) )
+ {
+ AppendText("\nFAILED TO SPAWN PROCESS\n");
+ return;
+ }
+
+ for (;;)
+ {
+ //------------------------------------------------------------------
+ // If the child process has completed, break out.
+ //------------------------------------------------------------------
+ if ( !m_hThread || MsgWaitForMultipleObjects( 1, &m_hThread, FALSE, 20, QS_ALLINPUT) == WAIT_OBJECT_0 )
+ {
+ break;
+ }
+
+ //------------------------------------------------------------------
+ // Peek and pump messages.
+ //------------------------------------------------------------------
+ PeekAndPump();
+
+ //------------------------------------------------------------------
+ // If the user cancelled the operation, terminate the process.
+ //------------------------------------------------------------------
+ if ( m_bStopped )
+ {
+ Close();
+ }
+ }
+}
+
+
+void CRedirect::PeekAndPump()
+{
+ MSG Msg;
+ while (::PeekMessage(&Msg, NULL, 0, 0, PM_NOREMOVE))
+ {
+ (void)AfxGetApp()->PumpMessage(); //lint !e1924 (warning about C-style cast)
+ }
+}
+
+void CRedirect::Stop()
+{
+ m_bStopped = true;
+}
+
+void CRedirect::AppendText(LPCTSTR Text)
+{
+ char *pszCurrent = const_cast<char *>(Text);
+ int Length;
+
+ Length = m_pEdit->GetWindowTextLength();
+ if ( Length + strlen(Text) > m_pEdit->GetLimitText() )
+ m_pEdit->SetLimitText( m_pEdit->GetLimitText() * 2 );
+
+ if ( *pszCurrent == '\n' )
+ pszCurrent++;
+
+ while ( pszCurrent && *pszCurrent )
+ {
+ char *pszLineEnd = strchr( pszCurrent, '\r' );
+ if ( pszLineEnd )
+ *pszLineEnd = 0;
+
+ Length = m_pEdit->GetWindowTextLength();
+ m_pEdit->SetSel(Length, Length);
+ m_pEdit->ReplaceSel(pszCurrent);
+ //OutputDebugString(pszCurrent);
+
+ if ( pszLineEnd )
+ {
+ Length = m_pEdit->GetWindowTextLength();
+ m_pEdit->SetSel(Length, Length);
+ m_pEdit->ReplaceSel("\r\n");
+ //OutputDebugString("\r\n");
+ }
+
+ m_pEdit->LineScroll( m_pEdit->GetLineCount() );
+ PeekAndPump();
+
+ if ( pszLineEnd )
+ {
+ *pszLineEnd = '\r';
+ pszCurrent = pszLineEnd + 1;
+ if ( *pszCurrent == '\n' )
+ pszCurrent++;
+ }
+ else
+ pszCurrent = NULL;
+ };
+}
+
+
+void CRedirect::WriteStdOut(LPCSTR pszOutput)
+{
+ AppendText( pszOutput );
+}
+
+void CRedirect::WriteStdError(LPCSTR pszError)
+{
+ AppendText( CString(pszError) );
+}
diff --git a/devtools/syncfrommirror/Redirect.h b/devtools/syncfrommirror/Redirect.h
new file mode 100644
index 0000000..560644d
--- /dev/null
+++ b/devtools/syncfrommirror/Redirect.h
@@ -0,0 +1,55 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+#include "redir.h"
+
+#ifndef REDIRECT_H_INCLUDED__
+#define REDIRECT_H_INCLUDED__
+
+class CRedirect : public CRedirector
+{
+public:
+
+ //--------------------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------------------
+ CRedirect()
+ : m_pEdit(NULL),
+ m_bStopped(false)
+ {
+ }
+
+ //--------------------------------------------------------------------------
+ // destructor
+ //--------------------------------------------------------------------------
+ virtual ~CRedirect();
+ //--------------------------------------------------------------------------
+ // public member functions
+ //--------------------------------------------------------------------------
+ virtual void Run(LPCTSTR szCommand, CEdit *pEdit, LPCTSTR pszCurrentDirectory = NULL);
+ virtual void Stop();
+
+protected:
+
+ //--------------------------------------------------------------------------
+ // member functions
+ //--------------------------------------------------------------------------
+ virtual void WriteStdOut(LPCSTR pszOutput);
+ virtual void WriteStdError(LPCSTR pszError);
+
+ void AppendText(LPCTSTR Text);
+ void PeekAndPump();
+
+ //--------------------------------------------------------------------------
+ // member data
+ //--------------------------------------------------------------------------
+ CEdit * m_pEdit;
+ bool m_bStopped;
+
+};
+
+#endif // REDIRECT_H_INCLUDED__
diff --git a/devtools/syncfrommirror/StdAfx.cpp b/devtools/syncfrommirror/StdAfx.cpp
new file mode 100644
index 0000000..83f04f3
--- /dev/null
+++ b/devtools/syncfrommirror/StdAfx.cpp
@@ -0,0 +1,15 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// stdafx.cpp : source file that includes just the standard includes
+// syncfrommirror.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
+
diff --git a/devtools/syncfrommirror/StdAfx.h b/devtools/syncfrommirror/StdAfx.h
new file mode 100644
index 0000000..0dcb5e1
--- /dev/null
+++ b/devtools/syncfrommirror/StdAfx.h
@@ -0,0 +1,33 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__819F1F09_8031_443C_B19C_AB6AAEA62789__INCLUDED_)
+#define AFX_STDAFX_H__819F1F09_8031_443C_B19C_AB6AAEA62789__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h> // MFC core and standard components
+#include <afxext.h> // MFC extensions
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h> // MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__819F1F09_8031_443C_B19C_AB6AAEA62789__INCLUDED_)
diff --git a/devtools/syncfrommirror/res/syncfrommirror.ico b/devtools/syncfrommirror/res/syncfrommirror.ico
new file mode 100644
index 0000000..0dd2e3f
--- /dev/null
+++ b/devtools/syncfrommirror/res/syncfrommirror.ico
Binary files differ
diff --git a/devtools/syncfrommirror/res/syncfrommirror.rc2 b/devtools/syncfrommirror/res/syncfrommirror.rc2
new file mode 100644
index 0000000..7dfb031
--- /dev/null
+++ b/devtools/syncfrommirror/res/syncfrommirror.rc2
@@ -0,0 +1,13 @@
+//
+// SYNCFROMMIRROR.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+ #error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/devtools/syncfrommirror/resource.h b/devtools/syncfrommirror/resource.h
new file mode 100644
index 0000000..899e96a
--- /dev/null
+++ b/devtools/syncfrommirror/resource.h
@@ -0,0 +1,34 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by syncfrommirror.rc
+//
+#define IDD_SYNCFROMMIRROR_DIALOG 102
+#define IDR_MAINFRAME 128
+#define IDC_EDIT1 1000
+#define IDC_EDIT2 1001
+#define IDC_CHECK1 1002
+#define IDC_CHECK2 1003
+#define IDC_CHECK3 1004
+#define IDC_CHECK4 1005
+#define IDC_DOD 1006
+#define IDC_BUTTON1 1007
+#define IDC_WORKINGFOLDER_DOD 1008
+#define IDC_MAKECOMMANDPROMPTS 1009
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_COMMAND_VALUE 32771
+#define _APS_NEXT_CONTROL_VALUE 1010
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/devtools/syncfrommirror/syncfrommirror.cpp b/devtools/syncfrommirror/syncfrommirror.cpp
new file mode 100644
index 0000000..dc4ce28
--- /dev/null
+++ b/devtools/syncfrommirror/syncfrommirror.cpp
@@ -0,0 +1,70 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// syncfrommirror.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "syncfrommirror.h"
+#include "syncfrommirrorDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CSyncfrommirrorApp
+
+BEGIN_MESSAGE_MAP(CSyncfrommirrorApp, CWinApp)
+ //{{AFX_MSG_MAP(CSyncfrommirrorApp)
+ //}}AFX_MSG
+ ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CSyncfrommirrorApp construction
+
+CSyncfrommirrorApp::CSyncfrommirrorApp()
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CSyncfrommirrorApp object
+
+CSyncfrommirrorApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+// CSyncfrommirrorApp initialization
+
+BOOL CSyncfrommirrorApp::InitInstance()
+{
+ // Standard initialization
+
+#ifdef _AFXDLL
+ Enable3dControls(); // Call this when using MFC in a shared DLL
+#else
+ Enable3dControlsStatic(); // Call this when linking to MFC statically
+#endif
+ AfxInitRichEdit();
+ SetRegistryKey( "Valve" );
+
+ CSyncfrommirrorDlg dlg;
+ m_pMainWnd = &dlg;
+ int nResponse = dlg.DoModal();
+ if (nResponse == IDOK)
+ {
+ }
+ else if (nResponse == IDCANCEL)
+ {
+ }
+
+ // Since the dialog has been closed, return FALSE so that we exit the
+ // application, rather than start the application's message pump.
+ return FALSE;
+}
diff --git a/devtools/syncfrommirror/syncfrommirror.h b/devtools/syncfrommirror/syncfrommirror.h
new file mode 100644
index 0000000..1c65563
--- /dev/null
+++ b/devtools/syncfrommirror/syncfrommirror.h
@@ -0,0 +1,54 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// syncfrommirror.h : main header file for the SYNCFROMMIRROR application
+//
+
+#if !defined(AFX_SYNCFROMMIRROR_H__1E25CDDD_8382_4580_81AC_CFB68FECBE4A__INCLUDED_)
+#define AFX_SYNCFROMMIRROR_H__1E25CDDD_8382_4580_81AC_CFB68FECBE4A__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#ifndef __AFXWIN_H__
+ #error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h" // main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CSyncfrommirrorApp:
+// See syncfrommirror.cpp for the implementation of this class
+//
+
+class CSyncfrommirrorApp : public CWinApp
+{
+public:
+ CSyncfrommirrorApp();
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CSyncfrommirrorApp)
+ public:
+ virtual BOOL InitInstance();
+ //}}AFX_VIRTUAL
+
+// Implementation
+
+ //{{AFX_MSG(CSyncfrommirrorApp)
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_SYNCFROMMIRROR_H__1E25CDDD_8382_4580_81AC_CFB68FECBE4A__INCLUDED_)
diff --git a/devtools/syncfrommirror/syncfrommirror.rc b/devtools/syncfrommirror/syncfrommirror.rc
new file mode 100644
index 0000000..740ae2e
--- /dev/null
+++ b/devtools/syncfrommirror/syncfrommirror.rc
@@ -0,0 +1,196 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+ "#define _AFX_NO_OLE_RESOURCES\r\n"
+ "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+ "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+ "\r\n"
+ "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+ "#ifdef _WIN32\r\n"
+ "LANGUAGE 9, 1\r\n"
+ "#pragma code_page(1252)\r\n"
+ "#endif //_WIN32\r\n"
+ "#include ""res\\syncfrommirror.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
+ "#include ""afxres.rc"" // Standard components\r\n"
+ "#endif\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME ICON DISCARDABLE "res\\syncfrommirror.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_SYNCFROMMIRROR_DIALOG DIALOGEX 0, 0, 384, 218
+STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
+ WS_THICKFRAME
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "Sync from VSS Mirror"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "Sync",IDOK,327,7,50,14
+ PUSHBUTTON "Exit",IDCANCEL,327,23,50,14
+ EDITTEXT IDC_EDIT2,65,20,83,12,ES_AUTOHSCROLL
+ LTEXT "Working Folder:",IDC_STATIC,14,21,51,11
+ CONTROL "HL2",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
+ 154,22,38,10
+ CONTROL "HL1Port",IDC_CHECK2,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,196,22,38,10
+ CONTROL "CSPort",IDC_CHECK3,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,196,34,38,10
+ CONTROL "TF2",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_DISABLED |
+ WS_TABSTOP,154,34,38,10
+ EDITTEXT IDC_EDIT1,7,88,316,123,ES_MULTILINE | ES_AUTOVSCROLL |
+ ES_AUTOHSCROLL | WS_VSCROLL
+ PUSHBUTTON "Stop",IDC_BUTTON1,327,58,50,14,NOT WS_VISIBLE |
+ WS_DISABLED
+ CONTROL "Day of Defeat",IDC_DOD,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,243,22,66,10
+ GROUPBOX "Main Projects",IDC_STATIC,7,7,309,46
+ GROUPBOX "Options",IDC_STATIC,7,55,309,29
+ CONTROL "Create a command prompt for each Robocopy",
+ IDC_MAKECOMMANDPROMPTS,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,15,67,161,10
+END
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "\0"
+ VALUE "FileDescription", "syncfrommirror MFC Application\0"
+ VALUE "FileVersion", "1, 0, 0, 1\0"
+ VALUE "InternalName", "syncfrommirror\0"
+ VALUE "LegalCopyright", "Copyright (C) 2003\0"
+ VALUE "LegalTrademarks", "\0"
+ VALUE "OriginalFilename", "syncfrommirror.EXE\0"
+ VALUE "ProductName", "syncfrommirror Application\0"
+ VALUE "ProductVersion", "1, 0, 0, 1\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_SYNCFROMMIRROR_DIALOG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 377
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 211
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+#include "res\syncfrommirror.rc2" // non-Microsoft Visual C++ edited resources
+#include "afxres.rc" // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/devtools/syncfrommirror/syncfrommirror.vpc b/devtools/syncfrommirror/syncfrommirror.vpc
new file mode 100644
index 0000000..beac7f9
--- /dev/null
+++ b/devtools/syncfrommirror/syncfrommirror.vpc
@@ -0,0 +1,60 @@
+//-----------------------------------------------------------------------------
+// SYNCFROMMIRROR.VPC
+//
+// Project Script
+//-----------------------------------------------------------------------------
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\devtools\bin"
+
+$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)"
+ $PrecompiledHeaderFile "Release/syncfrommirror.pch"
+ $EnableC++Exceptions "Yes (/EHsc)"
+ }
+}
+
+$Project "Syncfrommirror"
+{
+ $Folder "Source Files"
+ {
+ -$File "$SRCDIR\public\tier0\memoverride.cpp"
+
+ $File "Redir.cpp"
+ $File "Redirect.cpp"
+ $File "syncfrommirror.cpp"
+ $File "syncfrommirror.rc"
+ $File "syncfrommirrorDlg.cpp"
+ $File "StdAfx.cpp"
+ {
+ $Configuration
+ {
+ $Compiler
+ {
+ $Create/UsePrecompiledHeader "Create Precompiled Header (/Yc)"
+ }
+ }
+ }
+ }
+
+ $Folder "Header Files"
+ {
+ $File "Redir.h"
+ $File "Redirect.h"
+ $File "Resource.h"
+ $File "StdAfx.h"
+ $File "syncfrommirror.h"
+ $File "syncfrommirrorDlg.h"
+ }
+
+ $Folder "Resource Files"
+ {
+ $File "res\syncfrommirror.ico"
+ $File "res\syncfrommirror.rc2"
+ }
+}
diff --git a/devtools/syncfrommirror/syncfrommirrorDlg.cpp b/devtools/syncfrommirror/syncfrommirrorDlg.cpp
new file mode 100644
index 0000000..be5af9c
--- /dev/null
+++ b/devtools/syncfrommirror/syncfrommirrorDlg.cpp
@@ -0,0 +1,275 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// syncfrommirrorDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "syncfrommirror.h"
+#include "syncfrommirrorDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CSyncfrommirrorDlg dialog
+
+CSyncfrommirrorDlg::CSyncfrommirrorDlg(CWnd* pParent /*=NULL*/)
+ : CDialog(CSyncfrommirrorDlg::IDD, pParent)
+{
+ //{{AFX_DATA_INIT(CSyncfrommirrorDlg)
+ m_WorkingFolder = _T("");
+ m_bHL2 = FALSE;
+ m_bTF2 = FALSE;
+ m_bHL1Port = FALSE;
+ m_bDOD = FALSE;
+ m_bCSPort = FALSE;
+ m_bMakeCommandPrompts = FALSE;
+ //}}AFX_DATA_INIT
+ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CSyncfrommirrorDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CSyncfrommirrorDlg)
+ DDX_Control(pDX, IDC_EDIT1, m_Output);
+ DDX_Text(pDX, IDC_EDIT2, m_WorkingFolder);
+ DDX_Check(pDX, IDC_CHECK1, m_bHL2);
+ DDX_Check(pDX, IDC_CHECK2, m_bHL1Port);
+ DDX_Check(pDX, IDC_CHECK3, m_bCSPort);
+ DDX_Check(pDX, IDC_CHECK4, m_bTF2);
+ DDX_Check(pDX, IDC_MAKECOMMANDPROMPTS, m_bMakeCommandPrompts);
+ DDX_Check(pDX, IDC_DOD, m_bDOD);
+ //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CSyncfrommirrorDlg, CDialog)
+ //{{AFX_MSG_MAP(CSyncfrommirrorDlg)
+ ON_WM_PAINT()
+ ON_WM_SIZE()
+ ON_WM_QUERYDRAGICON()
+ ON_BN_CLICKED(IDC_BUTTON1, OnStop)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CSyncfrommirrorDlg message handlers
+
+BOOL CSyncfrommirrorDlg::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ SetIcon(m_hIcon, TRUE); // Set big icon
+ SetIcon(m_hIcon, FALSE); // Set small icon
+
+ m_bHL2 = AfxGetApp()->GetProfileInt( "settings", "hl2", 1 );
+ m_bHL1Port = AfxGetApp()->GetProfileInt( "settings", "hl1", 0 );
+ m_bCSPort = AfxGetApp()->GetProfileInt( "settings", "cstrike", 0 );
+ m_bDOD = AfxGetApp()->GetProfileInt( "settings", "dod", 0 );
+ m_bMakeCommandPrompts = AfxGetApp()->GetProfileInt( "settings", "makecommandprompts", 0 );
+ m_WorkingFolder = AfxGetApp()->GetProfileString( "settings", "working_folder" );
+
+ // Calculate layout info for resizing.
+ CRect rectDlg;
+ GetClientRect( &rectDlg );
+
+ // Edit control
+ CRect rectEdit;
+ GetDlgItem( IDC_EDIT1 )->GetWindowRect( &rectEdit );
+ ScreenToClient( rectEdit );
+ m_nEditRightMargin = rectDlg.right - rectEdit.right;
+ m_nEditBottomMargin = rectDlg.bottom - rectEdit.bottom;
+
+ // Buttons
+ CRect rectButton;
+ GetDlgItem( IDOK )->GetWindowRect( &rectButton );
+ ScreenToClient( rectButton );
+ m_nButtonOffset = rectDlg.right - rectButton.left;
+
+// LoadSettings();
+ UpdateData(false);
+ // TODO: Add extra initialization here
+
+ return TRUE; // return TRUE unless you set the focus to a control
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+// to draw the icon. For MFC applications using the document/view model,
+// this is automatically done for you by the framework.
+
+void CSyncfrommirrorDlg::OnPaint()
+{
+ if (IsIconic())
+ {
+ CPaintDC dc(this); // device context for painting
+
+ SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
+
+ // Center icon in client rectangle
+ int cxIcon = GetSystemMetrics(SM_CXICON);
+ int cyIcon = GetSystemMetrics(SM_CYICON);
+ CRect rect;
+ GetClientRect(&rect);
+ int x = (rect.Width() - cxIcon + 1) / 2;
+ int y = (rect.Height() - cyIcon + 1) / 2;
+
+ // Draw the icon
+ dc.DrawIcon(x, y, m_hIcon);
+ }
+ else
+ {
+ CDialog::OnPaint();
+ }
+}
+
+HCURSOR CSyncfrommirrorDlg::OnQueryDragIcon()
+{
+ return (HCURSOR) m_hIcon;
+}
+
+void CSyncfrommirrorDlg::RunSync( const char *pszType )
+{
+ static const char *pszCmdLine = "cmd.exe /c \\\\hl2vss.valvesoftware.com\\hl2vss\\win32\\syncfrommirror.bat %s %s";
+ if ( m_bMakeCommandPrompts )
+ pszCmdLine = "cmd.exe /k \\\\hl2vss.valvesoftware.com\\hl2vss\\win32\\syncfrommirror.bat %s %s";
+
+ CString strCmdLine;
+
+ CString &strMain = m_WorkingFolder;
+ strMain.TrimLeft(" \"");
+ strMain.TrimRight(" \"");
+
+ CString workingFolder;
+ workingFolder = "\"";
+ workingFolder += strMain;
+ workingFolder += "\"";
+
+ strCmdLine.Format(pszCmdLine, pszType, workingFolder.operator const char *() );
+
+ GetDlgItem(IDOK)->EnableWindow(FALSE);
+ GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
+ GetDlgItem(IDC_BUTTON1)->EnableWindow();
+
+ if ( m_bMakeCommandPrompts )
+ {
+ RunCommandLine( strCmdLine, "c:\\" );
+ }
+ else
+ {
+ m_Redirector.Run( strCmdLine, &m_Output, "c:\\" );
+ }
+
+ GetDlgItem(IDOK)->EnableWindow();
+ GetDlgItem(IDCANCEL)->EnableWindow();
+ GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
+}
+
+void CSyncfrommirrorDlg::RunCommandLine( const char *pCmdLine, const char *pWorkingDir )
+{
+ STARTUPINFO startupInfo;
+ memset( &startupInfo, 0, sizeof( startupInfo ) );
+ startupInfo.cb = sizeof( startupInfo );
+
+ PROCESS_INFORMATION pi;
+ memset( &pi, 0, sizeof( pi ) );
+
+ CreateProcess(
+ NULL,
+ (char*)pCmdLine,
+ NULL,
+ NULL,
+ FALSE,
+ CREATE_NEW_CONSOLE,
+ NULL,
+ pWorkingDir,
+ &startupInfo,
+ &pi );
+}
+
+void CSyncfrommirrorDlg::OnOK()
+{
+ UpdateData();
+
+ AfxGetApp()->WriteProfileInt( "settings", "hl2", m_bHL2 );
+ AfxGetApp()->WriteProfileInt( "settings", "hl1", m_bHL1Port );
+ AfxGetApp()->WriteProfileInt( "settings", "dod", m_bDOD );
+ AfxGetApp()->WriteProfileInt( "settings", "cstrike", m_bCSPort );
+ AfxGetApp()->WriteProfileInt( "settings", "makecommandprompts", m_bMakeCommandPrompts );
+ AfxGetApp()->WriteProfileString( "settings", "working_folder", m_WorkingFolder);
+
+ if ( m_WorkingFolder.GetLength() == 0 )
+ {
+ MessageBox( "You must set your working folder (e.g. u:\\dev)", "Error", MB_ICONWARNING );
+ return;
+ }
+
+ m_Output.SetSel( 0, -1 );
+ m_Output.Clear();
+
+ if (m_bHL2 && m_bHL1Port && m_bCSPort && m_bDOD )
+ {
+ RunSync( "all" );
+ }
+ else
+ {
+ if ( m_bHL2 )
+ RunSync( "hl2" );
+ if ( m_bHL1Port )
+ RunSync( "hl1" );
+ if ( m_bCSPort )
+ RunSync( "cstrike" );
+ if ( m_bDOD )
+ RunSync( "dod" );
+ }
+
+ // If it spawned command prompts, then exit.
+ if ( m_bMakeCommandPrompts )
+ EndDialog( 0 );
+
+ FlashWindow( TRUE );
+
+ //CDialog::OnOK();
+}
+
+void CSyncfrommirrorDlg::OnStop()
+{
+ m_Redirector.Stop();
+
+}
+
+void CSyncfrommirrorDlg::OnSize( UINT nType, int cx, int cy )
+{
+ if ( GetDlgItem( IDC_EDIT1 ) )
+ {
+ CRect rectDlg;
+ GetClientRect( &rectDlg );
+
+ CRect rectEdit;
+ GetDlgItem( IDC_EDIT1 )->GetWindowRect( &rectEdit );
+ ScreenToClient( rectEdit );
+ GetDlgItem( IDC_EDIT1 )->MoveWindow( rectEdit.left, rectEdit.top, ( rectDlg.right - m_nEditRightMargin ) - rectEdit.left, ( rectDlg.bottom - m_nEditBottomMargin ) - rectEdit.top, TRUE );
+
+ CRect rectButton;
+ GetDlgItem( IDOK )->GetWindowRect( &rectButton );
+ ScreenToClient( rectButton );
+ GetDlgItem( IDOK )->MoveWindow( rectDlg.right - m_nButtonOffset, rectButton.top, rectButton.Width( ), rectButton.Height( ), TRUE );
+
+ GetDlgItem( IDCANCEL )->GetWindowRect( &rectButton );
+ ScreenToClient( rectButton );
+ GetDlgItem( IDCANCEL )->MoveWindow( rectDlg.right - m_nButtonOffset, rectButton.top, rectButton.Width( ), rectButton.Height( ), TRUE );
+
+ GetDlgItem( IDC_BUTTON1 )->GetWindowRect( &rectButton );
+ ScreenToClient( rectButton );
+ GetDlgItem( IDC_BUTTON1 )->MoveWindow( rectDlg.right - m_nButtonOffset, rectButton.top, rectButton.Width( ), rectButton.Height( ), TRUE );
+ }
+
+ CDialog::OnSize( nType, cx, cy );
+}
diff --git a/devtools/syncfrommirror/syncfrommirrorDlg.h b/devtools/syncfrommirror/syncfrommirrorDlg.h
new file mode 100644
index 0000000..2c8e003
--- /dev/null
+++ b/devtools/syncfrommirror/syncfrommirrorDlg.h
@@ -0,0 +1,78 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// syncfrommirrorDlg.h : header file
+//
+
+#include "redirect.h"
+
+#if !defined(AFX_SYNCFROMMIRRORDLG_H__CCDE7319_F912_4B51_A526_4B718AE8E22A__INCLUDED_)
+#define AFX_SYNCFROMMIRRORDLG_H__CCDE7319_F912_4B51_A526_4B718AE8E22A__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+/////////////////////////////////////////////////////////////////////////////
+// CSyncfrommirrorDlg dialog
+
+class CSyncfrommirrorDlg : public CDialog
+{
+// Construction
+public:
+ CSyncfrommirrorDlg(CWnd* pParent = NULL); // standard constructor
+
+ void RunSync( const char *pszType );
+
+// Dialog Data
+ //{{AFX_DATA(CSyncfrommirrorDlg)
+ enum { IDD = IDD_SYNCFROMMIRROR_DIALOG };
+ CEdit m_Output;
+ CString m_WorkingFolder;
+ BOOL m_bHL2;
+ BOOL m_bTF2;
+ BOOL m_bHL1Port;
+ BOOL m_bDOD;
+ BOOL m_bCSPort;
+ BOOL m_bMakeCommandPrompts;
+ //}}AFX_DATA
+
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CSyncfrommirrorDlg)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ HICON m_hIcon;
+
+ CRedirect m_Redirector;
+
+ // Layout info for resizing.
+ int m_nEditRightMargin; // Distance from the right side of the edit control to the right side of the client area
+ int m_nEditBottomMargin; // Distance from the bottom of the edit control to the bottom of the client area
+ int m_nButtonOffset; // Distance from left side of buttons to the right side of the client area
+
+ void RunCommandLine( const char *pCmdLine, const char *pWorkingDir );
+
+ // Generated message map functions
+ //{{AFX_MSG(CSyncfrommirrorDlg)
+ virtual BOOL OnInitDialog();
+ afx_msg void OnPaint();
+ afx_msg HCURSOR OnQueryDragIcon();
+ virtual void OnOK();
+ afx_msg void OnStop();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_SYNCFROMMIRRORDLG_H__CCDE7319_F912_4B51_A526_4B718AE8E22A__INCLUDED_)