Skip to content

Commit a8f842c

Browse files
committed
add link script for powershell
1 parent 3887ac5 commit a8f842c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

game_clean/link.ps1

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<#
2+
.SYNOPSIS
3+
symlink files from a retail Team Fortress 2 build to a patched build
4+
#>
5+
6+
param (
7+
[Parameter(Mandatory=$true)]
8+
[string]$TF2Dir
9+
)
10+
11+
$VerbosePreference = "Continue"
12+
$OutPath = "$PSScriptRoot\..\game"
13+
$GameClean = "$PSScriptRoot\."
14+
15+
16+
function Make-Symlink {
17+
param (
18+
[String]$Path
19+
)
20+
21+
$linkpath = "$OutPath/$Path"
22+
$targetpath = "$TF2Dir/$Path"
23+
24+
Write-Verbose -Message "Linking $linkpath to $targetpath"
25+
New-Item -ItemType SymbolicLink -Path $linkpath -Target $targetpath
26+
}
27+
28+
function Glob-Symlink {
29+
param (
30+
[String]$Path,
31+
[String]$Glob
32+
)
33+
34+
Get-ChildItem -Path "$TF2Dir\$Path\*" -Include $Glob | % { $_.Name } | % { Make-Symlink -Path $Path/$_ }
35+
}
36+
37+
New-Item -ItemType Directory -Path $OutPath
38+
39+
Write-Verbose -Message "Copying $GameClean/copy/ to $OutPath"
40+
Copy-Item -Recurse -Force $GameClean/clean/* $OutPath
41+
42+
Write-Verbose -Message "Creating $OutPath/tf/materials"
43+
New-Item -Type Directory -Path $OutPath/tf/materials
44+
45+
$targets = "hl2","platform"
46+
$targets += ,"maps","media","resource","scripts" | % { "tf/$_" }
47+
$targets += ,"models","vgui" | % { "tf/materials/$_" }
48+
ForEach ($t in $targets) {
49+
Make-Symlink -Path $t
50+
}
51+
52+
Glob-Symlink -Glob '' -Path 'bin'
53+
ForEach ($g in '*.vpk','*.cache') { Glob-Symlink -Glob $g -Path 'tf' }

0 commit comments

Comments
 (0)