Skip to content

Commit f359977

Browse files
committed
file path was being expanded , now use literalpath
1 parent 2e1d6e2 commit f359977

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

http_listener.ps1

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
12
if ( $args -contains "disappear" ) {
23

34
$arguments = $args[1..($args.Length - 1)]
45
$ErrorActionPreference = 'Stop'
6+
# $ErrorActionPreference = 'Continue'
57

68
$HttpFile = ''
79
$AFile = 'user\sofplus\data\http_tmp'
810
$HttpServer = 'https://raw.githubusercontent.com/plowsof/sof1maps/main/'
911

1012
# Delete existing http file if it exists
11-
If (Test-Path $AFile) {
12-
Remove-Item $AFile
13+
If (Test-Path "$AFile") {
14+
Remove-Item "$AFile"
1315
Write-Host 'Deleting existing http file.'
1416
}
1517

@@ -23,54 +25,50 @@ $gameProcess = Start-Process -PassThru -FilePath 'SoF.exe' -ArgumentList $argume
2325
While ($true) {
2426
If (Test-Path $AFile) {
2527
# Read the last line of the mapname file
26-
$HttpFile = Get-Content $AFile | Select-Object -Last 1
28+
$HttpFile = Get-Content "$AFile" | Select-Object -Last 1
2729

2830
$HttpFile = $HttpFile.Split('"')[3]
2931
Write-Host "Map name: $HttpFile"
3032

3133
# Remove .bsp extension and add .zip extension
32-
$HttpFile = $HttpFile -replace '\.bsp$', '.zip'
34+
$HttpFile = "$HttpFile" -replace '\.bsp$', '.zip'
3335

3436
# Download the file from the http server
3537
$DestFile = Join-Path 'user\maps' $HttpFile
36-
38+
3739
# Create the directory if it doesn't exist
38-
$directory = Split-Path -Path $DestFile -Parent
39-
if (!(Test-Path -Path $directory -PathType Container)) {
40-
New-Item -Path $directory -ItemType Directory | Out-Null
40+
$directory = Split-Path -LiteralPath "$DestFile"
41+
if (!(Test-Path -LiteralPath "$directory" -PathType Container)) {
42+
New-Item -Path "$directory" -ItemType Directory | Out-Null
4143
}
44+
4245
# Download the file using Invoke-WebRequest
4346
Write-Host "NEUTRAL: Trying to download ""$HttpServer$HttpFile"" to ""$DestFile""."
44-
4547
try {
46-
$ProgressPreference = 'SilentlyContinue'
4748
$encodedUri = [System.Uri]::EscapeUriString("$HttpServer$HttpFile")
4849
$webClient = New-Object System.Net.WebClient
49-
$webClient.DownloadFile($encodedUri, $DestFile)
50+
$webClient.DownloadFile("$encodedUri", "$DestFile")
5051
Write-Host "SUCCESS: ""$HttpFile"" downloaded to ""$DestFile""."
5152

52-
# Read-Host -Prompt "Press Enter to continue..."
53-
5453
# Extract the zip file
55-
Expand-Archive -LiteralPath $DestFile -DestinationPath 'user' -Force
54+
Expand-Archive -LiteralPath "$DestFile" -DestinationPath 'user' -Force
5655

5756
# Delete the zip file
58-
Remove-Item $DestFile
57+
Remove-Item -LiteralPath "$DestFile"
5958

6059
} catch {
6160
# 404 error catch
6261
Write-Host "ERROR: $($_.Exception.Message)"
6362
}
6463
# Delete the http file
65-
Remove-Item $AFile
64+
Remove-Item -LiteralPath "$AFile"
6665
}
6766
# Wait for 2 seconds and check again
6867
Start-Sleep -Seconds 2
6968

7069
if ($gameProcess.HasExited) {
7170
exit
7271
}
73-
7472
}
7573
} else {
7674
# $arguments = "-ExecutionPolicy Bypass", "-File `"$PSCommandPath`"", "disappear"

user/sofplus/addons/http2.func

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function http2_init()
1919

2020
function http2_init_print()
2121
{
22-
echo "[HTTP] Version v1.9 Loaded"
22+
echo "[HTTP] Version v2.0 Loaded"
2323
}
2424

2525
//2 -> 4 -> 7 -> 8

0 commit comments

Comments
 (0)