A few apps are using some custom code for PAL (contained in Custom.nsh) I wrote to determine the PortableApps.com Documents directory when apps are run without the PA.c Platform. There is a bug in this code that I fixed today in the LibreOffice Portable 4.2.1 update (awaiting publisher posting). Here is the fixed code:
ExpandEnvStrings $1 "%PortableApps.comDocuments%"
${If} $1 == ""
${OrIfNot} ${FileExists} "$1\*.*"
${GetParent} $EXEDIR $3
${GetParent} $3 $1
${If} $1 == "" ;Be sure we didn't just GetParent on Root
StrCpy $1 $3
${EndIf}
${If} ${FileExists} "$1\Documents\*.*"
StrCpy $2 "$1\Documents"
${Else}
${GetRoot} $EXEDIR $1
${If} ${FileExists} "$1\Documents\*.*"
StrCpy $2 "$1\Documents"
${Else}
StrCpy $2 "$1"
${EndIf}
${EndIf}
System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("PortableApps.comDocuments", "$2").r0'
${EndIf}WHAT'S FIXED: The fix is specifically around when an app is run at the root of the drive (example: X:\AppNamePortable instead of X:\SomePathTo\AppNamePortable) which was causing an invalid path to result when GetParent is called on a variable with the root directory.
AFFECTED APPS: LibreOffice (fixed with the 4.2.1 release), LibreCad, Mp3splt, MPC-HC, PDF-XChangeViewer (dev test), possibly other Dev Test apps.
I've already updated the affected released apps internally and will have them updated with the fix with their next releases. I wanted to post this publicly so other devs can fix any dev test releases with this change.



As an add-on to the above, here's full custom code to interpolate all 4 custom folders (Documents, Videos, Pictures, Music) if they don't exist in their standard location:
${SegmentFile} ${SegmentInit} ExpandEnvStrings $1 "%PortableApps.comDocuments%" ${If} $1 == "" ${OrIfNot} ${FileExists} "$1\*.*" ${GetParent} $EXEDIR $3 ${GetParent} $3 $1 ${If} $1 == "" ;Be sure we didn't just GetParent on Root StrCpy $1 $3 ${EndIf} ${If} ${FileExists} "$1\Documents\*.*" StrCpy $2 "$1\Documents" ${Else} ${GetRoot} $EXEDIR $1 ${If} ${FileExists} "$1\Documents\*.*" StrCpy $2 "$1\Documents" ${Else} StrCpy $2 "$1" ${EndIf} ${EndIf} System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("PortableApps.comDocuments", "$2").r0' ${EndIf} ExpandEnvStrings $1 "%PortableApps.comVideos%" ${If} $1 == "" ${OrIfNot} ${FileExists} "$1\*.*" ExpandEnvStrings $1 "%PortableApps.comDocuments%" ${If} ${FileExists} "$1\Videos\*.*" StrCpy $2 "$1\Videos" ${Else} ${GetParent} $EXEDIR $3 ${GetParent} $3 $1 ${If} $1 == "" ;Be sure we didn't just GetParent on Root StrCpy $1 $3 ${EndIf} ${If} ${FileExists} "$1\Videos\*.*" StrCpy $2 "$1\Videos" ${Else} ${GetRoot} $EXEDIR $1 ${If} ${FileExists} "$1\Videos\*.*" StrCpy $2 "$1\Videos" ${Else} StrCpy $2 "$1" ${EndIf} ${EndIf} ${EndIf} System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("PortableApps.comVideos", "$2").r0' ${EndIf} ExpandEnvStrings $1 "%PortableApps.comPictures%" ${If} $1 == "" ${OrIfNot} ${FileExists} "$1\*.*" ExpandEnvStrings $1 "%PortableApps.comDocuments%" ${If} ${FileExists} "$1\Pictures\*.*" StrCpy $2 "$1\Pictures" ${Else} ${GetParent} $EXEDIR $3 ${GetParent} $3 $1 ${If} $1 == "" ;Be sure we didn't just GetParent on Root StrCpy $1 $3 ${EndIf} ${If} ${FileExists} "$1\Pictures\*.*" StrCpy $2 "$1\Pictures" ${Else} ${GetRoot} $EXEDIR $1 ${If} ${FileExists} "$1\Pictures\*.*" StrCpy $2 "$1\Pictures" ${Else} StrCpy $2 "$1" ${EndIf} ${EndIf} ${EndIf} System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("PortableApps.comPictures", "$2").r0' ${EndIf} ExpandEnvStrings $1 "%PortableApps.comMusic%" ${If} $1 == "" ${OrIfNot} ${FileExists} "$1\*.*" ExpandEnvStrings $1 "%PortableApps.comDocuments%" ${If} ${FileExists} "$1\Music\*.*" StrCpy $2 "$1\Music" ${Else} ${GetParent} $EXEDIR $3 ${GetParent} $3 $1 ${If} $1 == "" ;Be sure we didn't just GetParent on Root StrCpy $1 $3 ${EndIf} ${If} ${FileExists} "$1\Music\*.*" StrCpy $2 "$1\Music" ${Else} ${GetRoot} $EXEDIR $1 ${If} ${FileExists} "$1\Music\*.*" StrCpy $2 "$1\Music" ${Else} StrCpy $2 "$1" ${EndIf} ${EndIf} ${EndIf} System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("PortableApps.comMusic", "$2").r0' ${EndIf} !macroendSometimes, the impossible can become possible, if you're awesome!
Given the above, I presume there's nothing for me to do here?
It should be "prapped" btw