reaper-oss / sws

The SWS extension is a collection of features that seamlessly integrate into REAPER, the Digital Audio Workstation (DAW) software by Cockos, Inc
https://www.sws-extension.org/
MIT License
454 stars 85 forks source link

BR_Win32_GetPrivateProfileString crops spaces in front of the returned string #1590

Closed amagalma closed 2 years ago

amagalma commented 2 years ago

Set "Save to timestamped file in additional directory:" in Reaper Preferences\Project to " Backups".

Run the following in a lua script: autosavedir = ({reaper.BR_Win32_GetPrivateProfileString( "reaper", "autosavedir", "", reaper.get_ini_file() )})[2]

The returned string is "Backups" instead of " Backups".

cfillion commented 2 years ago

This trim "feature" comes from the old Windows 16-bit API. Try specifying ./ Backups in the preferences instead. (Surrounding the value in the .ini with quotes also works, although not applicable in this specific case.)

The ReaScript function is just a wrapper for its Windows equivalent. https://github.com/reaper-oss/sws/blob/5d31e552ad3bcec8e03b0344d1833ea4d2f5fbf6/Breeder/BR_ReaScript.cpp#L1087-L1093