-
Notifications
You must be signed in to change notification settings - Fork 788
/
Copy pathCopyMod.ps1
42 lines (38 loc) · 1.16 KB
/
CopyMod.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
param ($Mod, $ModsDir)
function CheckDir ([System.IO.DirectoryInfo]$dir) {
$res = $true;
foreach ($file in Get-ChildItem $dir.FullName) {
if ($file -is [System.IO.FileInfo]) {
if ((".dll", ".cs") -contains $file.Extension) {
$res = $false;
break;
}
}
else {
if (!(CheckDir $file)) {
$res = $false;
break;
}
}
}
return $res;
}
$path = Join-Path $PSScriptRoot $Mod;
$targetDir = Join-Path $ModsDir $Mod;
if (Test-Path $targetDir) {
Remove-Item "$targetDir\*" -Recurse -Force -Exclude *.xml, *.dll
foreach ($file in Get-ChildItem $path) {
if ($file -is [System.IO.FileInfo]) {
if ((".dll", ".cs") -notcontains $file.Extension) {
Write-Output ("copy file " + $file.Name)
Copy-Item -Force $file.FullName (Join-Path $targetDir $file.Name)
}
}
else {
if (CheckDir $file) {
Write-Output ("copy folder " + $file.Name)
Copy-Item -Force -Recurse $file.FullName $targetDir
}
}
}
}