Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 02-23-2024, 04:26 AM   #1
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Somewhere in this universe or so.
Posts: 1,697
Default API issue: on Mac GetProjectPathEx() gets the wrong path

inconsistent output between Win and Mac

Code:
local pj_path = reaper.GetProjectPathEx(0 , '' ):gsub("(.*)\\.*$","%1")
reaper.ShowConsoleMsg(pj_path)
I got

On Windows:
it returns the project path as expected
eg:
Code:
J:\Music Production\My Project
On Mac:
it returns the project path BUT it appends the path declared in Project Settings > tab MEDIA > field: Path to save media files
eg:
Code:
/Users/albv/Music Production/My Project/Audio files

NOTE: I didn't check on Linux. So please verify it on that environment as well
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository

Last edited by BartR; 02-23-2024 at 10:14 AM.
BartR is offline   Reply With Quote
Old 02-23-2024, 04:51 AM   #2
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,266
Default

Didn't test, but your regex looks like it was made for Windows only.

Try this:

Code:
local pj_path = reaper.GetProjectPathEx(0 , '' ):gsub("(.*)[\\/].*$","%1")
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is offline   Reply With Quote
Old 02-23-2024, 05:45 AM   #3
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Somewhere in this universe or so.
Posts: 1,697
Default

Quote:
Originally Posted by FeedTheCat View Post
Didn't test, but your regex looks like it was made for Windows only.

Try this:

Code:
local pj_path = reaper.GetProjectPathEx(0 , '' ):gsub("(.*)[\\/].*$","%1")
Later I will try it because I send all the scripts to a contact of mine that's working on Mac.
however, this is NOT the reason for which this bug exists.

However @the_metal_priest is testing all the code I send him. As soon as I have a feedback about this hint I will let you know

Even by using the full regex, the name of the folder must NOT be added by the API ...
It's a clear malfunctioning.
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository

Last edited by BartR; 02-23-2024 at 08:00 AM.
BartR is offline   Reply With Quote
Old 02-23-2024, 10:13 AM   #4
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Somewhere in this universe or so.
Posts: 1,697
Default

Quote:
Originally Posted by FeedTheCat View Post
Didn't test, but your regex looks like it was made for Windows only.

Try this:

Code:
local pj_path = reaper.GetProjectPathEx(0 , '' ):gsub("(.*)[\\/].*$","%1")
Hi FeedTheCat

yes the syntaxis you suggested solved ALSO that issue.

I still don't understand why that API was appending something not requested and not expected just for that syntaxis ... still something shouldn't happen.

That API should return the PROJECT path and not the optional rendering path ... whatever ...
so to me, still defective and it should be fixed.

Thank you a zillion.
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository
BartR is offline   Reply With Quote
Old 02-23-2024, 03:10 PM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,155
Default

Doc says 'Get the project recording path.'.
(and also confirmed by schwa).
nofish is offline   Reply With Quote
Old 02-24-2024, 02:31 AM   #6
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Somewhere in this universe or so.
Posts: 1,697
Default

Quote:
Originally Posted by nofish View Post
Doc says 'Get the project recording path.'.
(and also confirmed by schwa).
Uhmm but the API says: Get the PROJECT path.
Hence: inconsistency.

And moreover: by applying the syntaxis suggested by @FeedTheCat, it works as it is expected by its own name.
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository
BartR is offline   Reply With Quote
Old 02-24-2024, 02:58 AM   #7
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,665
Default

It gets the recording path. Yes, the functionname is a little misleading.

If you need the actual project path, use enumProjects and cut off the project filename.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 02-24-2024, 03:16 AM   #8
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Somewhere in this universe or so.
Posts: 1,697
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
It gets the recording path. Yes, the functionname is a little misleading.

If you need the actual project path, use enumProjects and cut off the project filename.
Thank you Meo-Ada for the hint.
I will study it and implement it.
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository
BartR is offline   Reply With Quote
Old 02-24-2024, 04:11 AM   #9
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,266
Default

Quote:
Originally Posted by BartR View Post
Uhmm but the API says: Get the PROJECT path.
Hence: inconsistency.
The description says: Get the project recording path.

And yes, the function name is a bit misleading, but changing it at this point would break thousands of scripts, so it's a big no no.

IIRC reaper.EnumProjects won't work with unsaved projects, so for many use cases that's a deal breaker.

I'd suggest using GetProjectPath and checking if it contains the default record path, if it does then taking it out of the path.

Something like this (test it, just briefly checked it):

Code:
local proj_path = reaper.GetProjectPath('')
local ret, rec_path = reaper.get_config_var_string('projdefrecpath')
-- If path contains media dir (rec_path) then remove it
if ret and proj_path:sub(#proj_path - #rec_path + 1) == rec_path then
    proj_path = proj_path:sub(1, #proj_path - #rec_path - 1)
end
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is offline   Reply With Quote
Old 02-24-2024, 04:51 AM   #10
BartR
Human being with feelings
 
BartR's Avatar
 
Join Date: Oct 2014
Location: Somewhere in this universe or so.
Posts: 1,697
Default

Quote:
Originally Posted by FeedTheCat View Post
The description says: Get the project recording path.

And yes, the function name is a bit misleading, but changing it at this point would break thousands of scripts, so it's a big no no.

IIRC reaper.EnumProjects won't work with unsaved projects, so for many use cases that's a deal breaker.

I'd suggest using GetProjectPath and checking if it contains the default record path, if it does then taking it out of the path.

Something like this (test it, just briefly checked it):

Code:
local proj_path = reaper.GetProjectPath('')
local ret, rec_path = reaper.get_config_var_string('projdefrecpath')
-- If path contains media dir (rec_path) then remove it
if ret and proj_path:sub(#proj_path - #rec_path + 1) == rec_path then
    proj_path = proj_path:sub(1, #proj_path - #rec_path - 1)
end
Thank you so much FeedTheCat
__________________
Reaper: always the most up-to-date.
O.S.: Windows 11 Pro
ReaPack (with bilingual Tutorials): https://bit.ly/ReaPack_Repository
BartR is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.