Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dae0123a17 |
+21
-2
@@ -17,6 +17,26 @@ function Require-Environment([string]$Name) {
|
||||
return $value
|
||||
}
|
||||
|
||||
function Test-PathIsWithinDirectory([string]$ParentDirectory, [string]$CandidateDirectory) {
|
||||
# [IO.Path]::GetRelativePath is not available in Windows PowerShell 5.1.
|
||||
# Compare complete paths with a separator boundary so, for example,
|
||||
# C:\workspace-other is not considered a child of C:\workspace.
|
||||
$parentPath = [IO.Path]::GetFullPath($ParentDirectory)
|
||||
$candidatePath = [IO.Path]::GetFullPath($CandidateDirectory)
|
||||
$directorySeparator = [IO.Path]::DirectorySeparatorChar.ToString()
|
||||
$alternateSeparator = [IO.Path]::AltDirectorySeparatorChar.ToString()
|
||||
|
||||
if ($candidatePath.Equals($parentPath, [StringComparison]::OrdinalIgnoreCase)) {
|
||||
return $true
|
||||
}
|
||||
|
||||
if (-not $parentPath.EndsWith($directorySeparator) -and -not $parentPath.EndsWith($alternateSeparator)) {
|
||||
$parentPath += $directorySeparator
|
||||
}
|
||||
|
||||
return $candidatePath.StartsWith($parentPath, [StringComparison]::OrdinalIgnoreCase)
|
||||
}
|
||||
|
||||
function Get-ActualArchitecture {
|
||||
$architecture = $env:PROCESSOR_ARCHITEW6432
|
||||
if ([string]::IsNullOrWhiteSpace($architecture)) {
|
||||
@@ -98,8 +118,7 @@ if ($HostArch -ne (Get-ActualArchitecture)) { Fail "host-arch '$HostArch' does n
|
||||
$workspaceDirectory = [IO.Path]::GetFullPath($Workspace)
|
||||
if ([IO.Path]::IsPathRooted($ProjectPath)) { Fail 'project-path must be relative to the checked-out workspace.' }
|
||||
$ProjectDirectory = [IO.Path]::GetFullPath((Join-Path $workspaceDirectory $ProjectPath))
|
||||
$projectRelativePath = [IO.Path]::GetRelativePath($workspaceDirectory, $ProjectDirectory)
|
||||
if ($projectRelativePath -eq '..' -or $projectRelativePath.StartsWith("..$([IO.Path]::DirectorySeparatorChar)") -or [IO.Path]::IsPathRooted($projectRelativePath)) { Fail 'project-path must remain inside the checked-out workspace.' }
|
||||
if (-not (Test-PathIsWithinDirectory $workspaceDirectory $ProjectDirectory)) { Fail 'project-path must remain inside the checked-out workspace.' }
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $ProjectDirectory 'project.godot') -PathType Leaf)) { Fail "No project.godot was found in project-path '$ProjectPath'." }
|
||||
$PresetFile = Join-Path $ProjectDirectory 'export_presets.cfg'
|
||||
if (-not (Test-Path -LiteralPath $PresetFile -PathType Leaf)) { Fail "No export_presets.cfg was found in project-path '$ProjectPath'." }
|
||||
|
||||
Reference in New Issue
Block a user