Advertisement
Guest User

Untitled

a guest
Oct 13th, 2021
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ZipNames = @(
  2.     "gong_libretro.dll.zip",
  3.     "squirreljme_libretro.dll.zip",
  4.     "potator_libretro.dll.zip",
  5.     "freeintv_libretro.dll.zip"
  6. )
  7. $CoreDest = "${PSScriptRoot}\cores\"
  8. $CoresBaseUri = "https://buildbot.libretro.com/nightly/windows/x86_64/latest/"
  9. $LogDest = "${PSScriptRoot}\core_update.log"
  10.  
  11. try
  12. {
  13.     Start-Transcript -Path $LogDest -UseMinimalHeader
  14. }
  15. catch [System.Management.Automation.ParameterBindingException]
  16. {
  17.     Start-Transcript -Path $LogDest
  18. }
  19.  
  20.  
  21. foreach ($zip in $ZipNames)
  22. {
  23.     $dll = $zip -replace '\.zip$', ''
  24.     $params = @{
  25.         "LiteralPath" = (Join-Path $CoreDest $dll)
  26.         "ErrorAction" = "SilentlyContinue"
  27.     }
  28.     if (($creationTime = (Get-Item @params).CreationTime) -and
  29.         (New-TimeSpan $creationTime (Get-Date)).Days -lt 7)
  30.     {
  31.         Write-Host "Skipping core ${dll}: It's not older than a week."
  32.         continue
  33.     }
  34.  
  35.     $params = @{
  36.         "Uri"     = ($CoresBaseUri + $zip)
  37.         "OutFile" = ($CoreDest + $zip)
  38.         "Verbose" = $true
  39.     }
  40.     try
  41.     {
  42.         Invoke-WebRequest @params
  43.     }
  44.     catch
  45.     {
  46.         Write-Host "Skipping core ${dll}: Failed to download ${zip}."
  47.         continue
  48.     }
  49.    
  50.     $params = @{
  51.         "LiteralPath"     = ($CoreDest + $zip)
  52.         "DestinationPath" = $CoreDest
  53.         "Force"           = $true
  54.         "Verbose"         = $true
  55.     }
  56.     Expand-Archive @params
  57.     Remove-Item ($CoreDest + $zip) -Verbose
  58. }
  59.  
  60. Stop-Transcript
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement