# parent dir of this actual script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f
function Readlink-f {
Param($Link)
- $Return = $null
- $c = 0
- $max = 100 # just in case we end up in a loop
- [bool] $found = 0
- $file = Get-Item -Path $Link
- $prevfile = $null
- While ( $c -lt $max -and "${file}" -ne "${prevfile}" -and -not $found ) {
- $prevfile = $file
- [string] $target = ( $file ).Target
- If ( $target -eq $null -or ( $file ).LinkType -ne "SymbolicLink" ) {
- $Return = $file
- $found = 1
- } Else {
- If ( $( Split-Path -Path $target -IsAbsolute ) ) {
- $file = Get-Item -Path $target
- } Else {
- # symbolic link is relative: combine previous link parent dir with the link target and resolve
- $file = Get-Item -Path ( Join-Path -Path ( Split-Path -Path $prevfile -Parent ) -ChildPath $target -Resolve )
- }
- }
- $c++
+ $dirs = @()
+ $dir = Convert-Path $Link
+ while ( $dir ) {
+ $dirs = @( Split-Path $dir -Leaf ) + $dirs
+ $dir = Split-Path $dir -Parent
}
- if ( -not $found ) {
- throw "Could not determine path to actual file $( Split-Path -Path $Link -Leaf )"
+ $real = Get-Item "/"
+ foreach ($d in $dirs) {
+ $real = Join-Path -Path $real -ChildPath $d
+ $item = Get-Item $real
+ if ($item.Target -ne $null) {
+ $real = Convert-Path $item.Target
+ }
}
- $Return
+ $real
}
# Avert problem with unix version of powershell and tell user the reason (Windows must always have .ps1 extension)
# parent dir of this actual script (which should be the getdown appdir/bin). Follow all symlinks. Like GNU readlink -f
function Readlink-f {
Param($Link)
- $Return = $null
- $c = 0
- $max = 100 # just in case we end up in a loop
- [bool] $found = 0
- $file = Get-Item -Path $Link
- $prevfile = $null
- While ( $c -lt $max -and "${file}" -ne "${prevfile}" -and -not $found ) {
- $prevfile = $file
- [string] $target = ( $file ).Target
- If ( $target -eq $null -or ( $file ).LinkType -ne "SymbolicLink" ) {
- $Return = $file
- $found = 1
- } Else {
- If ( $( Split-Path -Path $target -IsAbsolute ) ) {
- $file = Get-Item -Path $target
- } Else {
- # symbolic link is relative: combine previous link parent dir with the link target and resolve
- $file = Get-Item -Path ( Join-Path -Path ( Split-Path -Path $prevfile -Parent ) -ChildPath $target -Resolve )
- }
- }
- $c++
+ $dirs = @()
+ $dir = Convert-Path $Link
+ while ( $dir ) {
+ $dirs = @( Split-Path $dir -Leaf ) + $dirs
+ $dir = Split-Path $dir -Parent
}
- if ( -not $found ) {
- throw "Could not determine path to actual file $( Split-Path -Path $Link -Leaf )"
+ $real = Get-Item "/"
+ foreach ($d in $dirs) {
+ $real = Join-Path -Path $real -ChildPath $d
+ $item = Get-Item $real
+ if ($item.Target -ne $null) {
+ $real = Convert-Path $item.Target
+ }
}
- $Return
+ $real
}
# Avert problem with unix version of powershell and tell user the reason (Windows must always have .ps1 extension)
}
# we should always have at least one JVMARGS and GDL_ARGS so this is okay
-$myJvmArgsString = '`"' + $($JVMARGS -join '`" `"') + '`"'
-$myGdlArgsString = '`"' + $($GDL_ARGS -join '`" `"') + '`"'
+$myJvmArgsString = '"' + $($JVMARGS -join '" "') + '"'
+$myGdlArgsString = '"' + $($GDL_ARGS -join '" "') + '"'
# quote the args and the command (in case of spaces) with escape chars (`) and precede with & to indicate a command not string
$COMMAND = "& `"${JAVA}`" ${myJvmArgsString} -cp `"${GDL_CLASSPATH}`" com.threerings.getdown.launcher.GetdownApp ${myGdlArgsString}"