Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($PSVersionTable.PSVersion.Major -lt 5) {
- Write-Error "Powershell version 5 or later is required."
- exit 1
- }
- function Compare-With-Current-Dxlib-Version ($dxlib_txt, $dxlib_expect_version) {
- return (Test-Path $dxlib_txt) -And ($dxlib_expect_version -eq ([regex]"Ver ([0-9]+\.[0-9a-z]+)").Matches((Get-Content $dxlib_txt))[0].Groups[1].value.Replace(".", "_"));
- }
- $first_dir = (Get-Location).Path
- [System.Console]::Write("fetch DxLib...")
- $dlhtml = Invoke-WebRequest -Uri "http://dxlib.o.oo7.jp/dxdload.html"
- try {
- $dst = $dlhtml -match '<A HREF="(http[s]*:\/\/[^/]+\/DxLib\/DxLib_VC[\d\w_/.:]+\.(exe|zip))">'
- } catch {
- exit 1
- }
- $dllink = $matches[1];
- $dlext = $matches[2];
- $dst = $dllink -match "DxLib_VC([\d\w_/.:]+)\.$dlext"
- $dxlib_version = $matches[1];
- Write-Output "done."
- $dxlib_txt = "DxLib_VC\DxLib.txt"
- if ((Test-Path "DxLib_VC") -And (Compare-With-Current-Dxlib-Version $dxlib_txt $dxlib_version)){
- Write-Output "DxLib version $dxlib_version detect. skip install."
- } else {
- if (!(Test-Path "DxLib_VC$dxlib_version.$dlext")) {
- Write-Output "Downloading DxLib($dxlib_version) from: $dllink"
- Invoke-WebRequest -Uri $dllink -OutFile "DxLib_VC$dxlib_version.$dlext"
- Write-Output "done."
- } else {
- Write-Output "DxLib_VC$dxlib_version.$dlext found. Download skip."
- }
- [System.Console]::Write("Extracting...")
- Rename-Item -path "DxLib_VC" -newName "DxLib_VC_old"
- if ($dlext -eq "zip") {
- $zip_path = "DxLib_VC$dxlib_version.zip";
- $zip = Get-Item $zip_path
- $dirname = $zip.Basename
- New-Item -Force -ItemType directory -Path $dirname
- if (0 -eq $PSVersionTable.PSVersion.Minor) {
- Expand-Archive $zip_path -OutputPath $dirname
- } else {
- Expand-Archive -Path $zip_path -DestinationPath $dirname
- }
- Move-Item -Path "$dirname/DxLib_VC" -Destination "DxLib_VC"
- Remove-Item -path $dirname -recurse -force
- } else {
- Start-Process -FilePath "DxLib_VC$dxlib_version.exe" -Wait
- }
- if ((Test-Path "DxLib_VC") -And (Compare-With-Current-Dxlib-Version $dxlib_txt $dxlib_version)) {
- Write-Output "done."
- [System.Console]::Write("Delete old DxLib_VC and temporary file...")
- Remove-Item -path "DxLib_VC_old" -recurse -force
- Remove-Item -path "DxLib_VC$dxlib_version.$dlext" -ErrorAction Ignore
- Write-Output "done."
- } else {
- Rename-Item -path "DxLib_VC_old" -newName "DxLib_VC"
- Write-Output "failed."
- exit 1
- }
- }
- Set-Location "DxLib_VC\プロジェクトに追加すべきファイル_VC用"
- $cu_dir = (Get-Location).Path
- Write-Output "$cu_dir exist."
- [System.Console]::Write("setting to environment variable...")
- Set-Location $first_dir
- $env:DXLIB_ROOT=”$cu_dir”
- Write-Output "done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement