mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-07 17:29:36 +00:00
1
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// getmirror.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
@@ -0,0 +1,30 @@
|
||||
//========= 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__F801E6AC_EC64_4BD5_884B_439B27F83C9A__INCLUDED_)
|
||||
#define AFX_STDAFX_H__F801E6AC_EC64_4BD5_884B_439B27F83C9A__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include "windows.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__F801E6AC_EC64_4BD5_884B_439B27F83C9A__INCLUDED_)
|
||||
@@ -0,0 +1,145 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "stdafx.h"
|
||||
#include <string>
|
||||
#include <ctype.h>
|
||||
#include <wchar.h>
|
||||
#include <assert.h>
|
||||
#include <direct.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void rmkdir( const char *pszPath )
|
||||
{
|
||||
char *pszScan = const_cast<char*>(pszPath);
|
||||
|
||||
if ( *pszScan == '\\' && *(pszScan + 1) == '\\' )
|
||||
{
|
||||
assert( 0 );
|
||||
}
|
||||
else if ( *pszScan && *(pszScan + 1) == ':' && *(pszScan + 2) == '\\' )
|
||||
{
|
||||
pszScan += 3;
|
||||
}
|
||||
|
||||
char *pszLimit = pszScan + strlen( pszScan ) + 1;
|
||||
|
||||
while ( pszScan < pszLimit )
|
||||
{
|
||||
if ( *pszScan == '\\' || *pszScan == 0 )
|
||||
{
|
||||
char temp = *pszScan;
|
||||
*pszScan = 0;
|
||||
_mkdir( pszPath );
|
||||
*pszScan = temp;
|
||||
}
|
||||
pszScan++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char input[1024*16];
|
||||
|
||||
string notCopied;
|
||||
|
||||
if ( argc != 3 )
|
||||
{
|
||||
printf( "wrong arguments\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
string sourceRoot(argv[1]);
|
||||
string workingFolder(argv[2]);
|
||||
|
||||
if ( !workingFolder.length() )
|
||||
return 1;
|
||||
|
||||
if ( workingFolder[workingFolder.length()] != '\\' )
|
||||
workingFolder += "\\";
|
||||
|
||||
if ( !sourceRoot.length() )
|
||||
return 1;
|
||||
|
||||
if ( sourceRoot[sourceRoot.length()] != '\\' )
|
||||
sourceRoot += "\\";
|
||||
|
||||
int lenRoot = sourceRoot.length();
|
||||
|
||||
int count = 0;
|
||||
unsigned nKBytesCopied = 0;
|
||||
time_t startTime = time(NULL);
|
||||
|
||||
while ( gets(input) )
|
||||
{
|
||||
char *pszName = strstr(input, argv[1] );
|
||||
if ( !pszName )
|
||||
continue;
|
||||
|
||||
if ( strlen(pszName) - lenRoot <= 0 )
|
||||
continue;
|
||||
|
||||
string dest = workingFolder + ( pszName + lenRoot );
|
||||
string destDir = dest;
|
||||
|
||||
destDir.erase( destDir.rfind( '\\' ) );
|
||||
rmkdir( destDir.c_str() );
|
||||
|
||||
DWORD attributes = GetFileAttributes( dest.c_str() );
|
||||
if ( attributes != -1 && !(attributes & FILE_ATTRIBUTE_READONLY) )
|
||||
{
|
||||
notCopied += '\n';
|
||||
notCopied += dest;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( attributes != -1 )
|
||||
SetFileAttributes( dest.c_str(), (attributes & ~FILE_ATTRIBUTE_READONLY ) );
|
||||
|
||||
printf("%s\n", dest.c_str() );
|
||||
fflush(NULL);
|
||||
if ( !CopyFile( pszName, dest.c_str(), false ) )
|
||||
{
|
||||
printf( " Failed to copy %s!\n", dest.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
struct _stat fileStat;
|
||||
_stat( dest.c_str(), &fileStat );
|
||||
nKBytesCopied += fileStat.st_size / 1024;
|
||||
}
|
||||
|
||||
attributes = GetFileAttributes( dest.c_str() );
|
||||
SetFileAttributes( dest.c_str(), (attributes | FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE) );
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
if ( count )
|
||||
{
|
||||
printf( "%d files copied\n", count );
|
||||
printf( "%dk copied\n", nKBytesCopied );
|
||||
}
|
||||
|
||||
if ( notCopied.length() )
|
||||
{
|
||||
printf( "** The following files were not copied because they are writable **\n" );
|
||||
printf( notCopied.c_str() );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
printf("%d seconds\n", time(NULL) - startTime);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// GETMIRROR.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro OUTBINDIR "$SRCDIR\devtools\bin"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)"
|
||||
$PrecompiledHeaderFile "Debug/getmirror.pch"
|
||||
$EnableC++Exceptions "Yes (/EHsc)"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Getmirror"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
$File "getmirror.cpp"
|
||||
$File "StdAfx.cpp"
|
||||
{
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$Create/UsePrecompiledHeader "Create Precompiled Header (/Yc)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
$File "StdAfx.h"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
@echo off
|
||||
if .%1.== ."". goto usage
|
||||
if .%2.==.. goto hl2
|
||||
setlocal
|
||||
set dest=%2
|
||||
|
||||
if %1 == all goto all
|
||||
if %1 == hl2 goto hl2
|
||||
if %1 == hl1 goto hl1
|
||||
if %1 == cstrike goto cstrike
|
||||
if %1 == goldsrc goto goldsrc
|
||||
|
||||
|
||||
:all
|
||||
set source=\\hl2vss\hl2vss_mirror\hl2\release\dev
|
||||
time /t
|
||||
echo Syncing from $/hl2/release/dev to %dest% (via %source%)
|
||||
set source=\\hl2vss\hl2vss_mirror\hl2\release\dev
|
||||
\\hl2vss\hl2vss\win32\robocopy %source% %dest% /e /xo /copy:dat /w:5 /xx /ns /nc /ndl /np /fp /l /njh /njs | \\hl2vss\hl2vss\win32\getmirror.exe %source% %dest%
|
||||
set source=\\hl2vss\hl1ports_mirror\hl1ports\release\dev\hl1
|
||||
echo Syncing from $/hl1ports/release/dev/hl1 to %dest%\hl1 (via %source%)
|
||||
\\hl2vss\hl2vss\win32\robocopy %source% %dest%\hl1 /e /xo /copy:dat /w:5 /xx /ns /nc /ndl /np /fp /l /njh /njs | \\hl2vss\hl2vss\win32\getmirror.exe %source% %dest%\hl1
|
||||
set source=\\hl2vss\hl1ports_mirror\hl1ports\release\dev\cstrike
|
||||
echo Syncing from $/hl1ports/release/dev/cstrike to %dest%\cstrike (via %source%)
|
||||
\\hl2vss\hl2vss\win32\robocopy %source% %dest%\cstrike /e /xo /copy:dat /w:5 /xx /ns /nc /ndl /np /fp /l /njh /njs | \\hl2vss\hl2vss\win32\getmirror.exe %source% %dest%\cstrike
|
||||
time /t
|
||||
goto end
|
||||
|
||||
:hl2
|
||||
if .%2.==.. set dest=%1
|
||||
set source=\\hl2vss\hl2vss_mirror\hl2\release\dev
|
||||
echo Syncing from $/hl2/release/dev to %dest% (via %source%)
|
||||
echo.
|
||||
time /t
|
||||
\\hl2vss\hl2vss\win32\robocopy %source% %dest% /e /xo /copy:dat /w:5 /xx /ns /nc /ndl /np /fp /l /njh /njs | \\hl2vss\hl2vss\win32\getmirror.exe %source% %dest%
|
||||
time /t
|
||||
goto end
|
||||
|
||||
:hl1
|
||||
set source=\\hl2vss\hl1ports_mirror\hl1ports\release\dev\hl1
|
||||
echo Syncing from $/hl1ports\release\dev\cstrike to %dest%\hl1 (via %source%)
|
||||
echo.
|
||||
time /t
|
||||
\\hl2vss\hl2vss\win32\robocopy %source% %dest%\hl1 /e /xo /copy:dat /w:5 /xx /ns /nc /ndl /np /fp /l /njh /njs | \\hl2vss\hl2vss\win32\getmirror.exe %source% %dest%\hl1
|
||||
time /t
|
||||
goto end
|
||||
|
||||
:cstrike
|
||||
set source=\\hl2vss\hl1ports_mirror\hl1ports\release\dev\cstrike
|
||||
echo Syncing from $/hl1ports\release\dev\cstrike to %dest%\cstrike (via %source%)
|
||||
echo.
|
||||
time /t
|
||||
\\hl2vss\hl2vss\win32\robocopy %source% %dest%\cstrike /e /xo /copy:dat /w:5 /xx /ns /nc /ndl /np /fp /l /njh /njs | \\hl2vss\hl2vss\win32\getmirror.exe %source% %dest%\cstrike
|
||||
time /t
|
||||
goto end
|
||||
|
||||
:goldsrc
|
||||
set source=\\goldsource\goldsrc_mirror\hl1\release\dev
|
||||
echo Syncing from $/hl1\release\dev\ to %dest% (via %source%)
|
||||
echo.
|
||||
time /t
|
||||
\\goldsource\gldsrc\win32\robocopy %source% %dest% /e /xo /copy:dat /w:5 /xx /ns /nc /ndl /np /fp /l /njh /njs | \\goldsource\gldsrc\win32\getmirror.exe %source% %dest%
|
||||
time /t
|
||||
goto end
|
||||
|
||||
:needdest
|
||||
:Usage
|
||||
echo . Usage: syncfrommirror.bat [all][hl2][hl1][cstrike][goldsrc][local destination]
|
||||
echo .
|
||||
echo .
|
||||
echo .
|
||||
echo . Where all sync up to all mirror targets into your destination folder
|
||||
echo . hl2 sync up to $/hl2/release/dev into your destination folder
|
||||
echo . hl1 sync up to $/hl1ports/release/dev/hl1 into your destination folder
|
||||
echo . cstrike sync up to $/h1ports/release/dev/cstrike into your destination folder
|
||||
echo . goldsrc sync up to $/hl1/release/dev into your destination folder
|
||||
echo .
|
||||
echo . If you are syncing to hl1 or cstrike, your destination should be your base
|
||||
echo . folder with the engine in it (e.g. \hl2\release\dev\)
|
||||
echo .
|
||||
goto end
|
||||
|
||||
|
||||
:end
|
||||
Reference in New Issue
Block a user