Skip to content

Commit 595ca0b

Browse files
committed
add link script for powershell
1 parent 828c8e8 commit 595ca0b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

link.ps1

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
13+
14+
function Make-Symlink {
15+
param (
16+
[String]$Path
17+
)
18+
19+
$linkpath = "./game/$Path"
20+
$targetpath = "$TF2Dir/$Path"
21+
22+
Write-Verbose -Message "Linking $linkpath to $targetpath"
23+
New-Item -ItemType SymbolicLink -Path $linkpath -Target $targetpath
24+
}
25+
26+
function Glob-Symlink {
27+
param (
28+
[String]$Path,
29+
[String]$Glob
30+
)
31+
32+
Get-ChildItem -Path "$TF2Dir\$Path\*" -Include $Glob | % { $_.Name } | % { Make-Symlink -Path $Path/$_ }
33+
}
34+
35+
36+
Write-Verbose -Message "Copying ./game_clean/copy/ to ./game/"
37+
Copy-Item -Recurse -Force ./game_clean/copy/* ./game/
38+
39+
Write-Verbose -Message "Creating ./game/tf/materials"
40+
New-Item -Type Directory -Path ./game/tf/materials
41+
42+
$targets = "hl2","platform"
43+
$targets += ,"maps","media","resource","scripts" | % { "tf/$_" }
44+
$targets += ,"models","vgui" | % { "tf/materials/$_" }
45+
ForEach ($t in $targets) {
46+
Make-Symlink -Path $t
47+
}
48+
49+
Glob-Symlink -Glob '' -Path 'bin'
50+
ForEach ($g in '*.vpk','*.cache') { Glob-Symlink -Glob $g -Path 'tf' }
51+
52+
Write-Verbose -Message "Copying $TF2Dir/tf/gamestate.txt to ./game/tf"
53+
Copy-Item -Force $TF2Dir/tf/gamestate.txt ./game/tf/
54+
55+
Write-Verbose -Message "Copying $TF2Dir/tf/cfg to ./game/tf/cfg"
56+
Copy-Item -Recurse -Force $TF2Dir/tf/cfg/ ./game/tf/

0 commit comments

Comments
 (0)