summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2024-09-14 06:51:23 +0800
committerGitHub <[email protected]>2024-09-14 06:51:23 +0800
commit8dab4c87e8cd9e2a2ae106c7a0236294246478b2 (patch)
tree43828dae7056131a4b717aefece411b9bd310f53 /xmake/scripts
parent8cfa4e691396c5c9ded6ed5ab45b8a45a73bd01f (diff)
parent5994ea556a485b2a6ddecaafb60d5528def6dddb (diff)
Merge pull request #5616 from xmake-io/ps
download file using powershell
Diffstat (limited to 'xmake/scripts')
-rwxr-xr-xxmake/scripts/download.ps127
-rwxr-xr-xxmake/scripts/unzip.ps124
2 files changed, 51 insertions, 0 deletions
diff --git a/xmake/scripts/download.ps1 b/xmake/scripts/download.ps1
new file mode 100755
index 000000000..c19983699
--- /dev/null
+++ b/xmake/scripts/download.ps1
@@ -0,0 +1,27 @@
+#!/usr/bin/env pwsh
+#Requires -version 5
+
+param (
+ [string]$url,
+ [string]$outputfile
+)
+
+& {
+ function writeErrorTip($msg) {
+ Write-Host $msg -BackgroundColor Red -ForegroundColor White
+ }
+
+ $temppath = ([System.IO.Path]::GetTempPath(), $env:TMP, $env:TEMP, "$(Get-Location)" -ne $null)[0]
+ [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
+
+ function download {
+ try {
+ Invoke-Webrequest $url -OutFile $outputfile -UseBasicParsing
+ } catch {
+ writeErrorTip 'Download failed!'
+ throw
+ }
+ }
+
+ download
+}
diff --git a/xmake/scripts/unzip.ps1 b/xmake/scripts/unzip.ps1
new file mode 100755
index 000000000..46947bfd3
--- /dev/null
+++ b/xmake/scripts/unzip.ps1
@@ -0,0 +1,24 @@
+#!/usr/bin/env pwsh
+#Requires -version 5
+
+param (
+ [string]$archivefile,
+ [string]$outputdir
+)
+
+& {
+ function writeErrorTip($msg) {
+ Write-Host $msg -BackgroundColor Red -ForegroundColor White
+ }
+
+ function unzip {
+ try {
+ Expand-Archive -Path $archivefile -DestinationPath $outputdir
+ } catch {
+ writeErrorTip 'Unzip failed!'
+ throw
+ }
+ }
+
+ unzip
+}