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

Reply
 
Thread Tools Display Modes
Old 04-08-2018, 11:33 AM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,430
Default API: reaper.RecursiveCreateDirectory giving inconsistent return values

I've run into a situation where reaper.RCD successfully creates a folder but returns 0, which trips up my script's error handling. Reaper 5.78, Win 8.1 x64.

Code:
local ret = reaper.RecursiveCreateDirectory("C:\\test", 0)
--> 1 and c:\test now exists, as per the API.

local ret = reaper.RecursiveCreateDirectory("C:\\Users\\REDACTED\\AppData\\Roaming\\
REAPER\\Scripts\\Lokasenna\\Lokasenna_GUI\\compiled", 0)
--> 0, but ...\compiled now exists anyway
Cheers.
Lokasenna is offline   Reply With Quote
Old 04-08-2018, 12:30 PM   #2
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 12,566
Default

Is it possible that the directory already existed? In this case the function returns error...
Justin is offline   Reply With Quote
Old 04-08-2018, 02:07 PM   #3
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,430
Default

Nope. I'm watching it get created in Explorer.

A separate return value for "already exists" wouldn't be a bad idea, though, since last I checked reaper.file_exists() didn't work for folders.
Lokasenna is offline   Reply With Quote
Old 11-16-2019, 09:15 AM   #4
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,430
Default

Bump; this is still a problem on both Windows 8.1 and Ubuntu 19.whatever.

Code:
File.ensurePathExists = function(path)
  if reaper.file_exists(path) then return true end
  local ret = reaper.RecursiveCreateDirectory(path, 0)
  Msg("reaper.RecursiveCreateDirectory returned: " .. ret)

  if ret == 1 then return true end

  error("The specified path does not exist, and could not be created:\n" .. path)
end
- Folder doesn't exist
- Run the script
- Folder is created
- Errors out anyway:

Code:
reaper.RecursiveCreateDirectory returned: 0

Error: file.lua:102: The specified path does not exist, and could not be created:
/home/adam/Coding/Reaper/Scythe/development/docs/rough/
Lokasenna is offline   Reply With Quote
Old 11-16-2019, 09:18 AM   #5
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,430
Default

I think I found the culprit - looks like it doesn't like paths with a trailing slash.
Lokasenna 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 09:12 PM.


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