Skip to content

Instantly share code, notes, and snippets.

@X-Raym
Last active February 28, 2023 12:59
Show Gist options
  • Save X-Raym/8997d16f5e914f151f937d6c8e7e17a9 to your computer and use it in GitHub Desktop.
Save X-Raym/8997d16f5e914f151f937d6c8e7e17a9 to your computer and use it in GitHub Desktop.
os_sep = package.config:sub(1,1)
-- Check if folder exists --
local function FolderExists(strFolderName)
if strFolderName:len() == 0 then return false end
strFolderName = strFolderName:gsub( os_sep .. "$", "" )
if os_sep == "\\" then strFolderName = strFolderName .. os_sep .. "*.*" end
local fileHandle, strError = io.open(strFolderName , "r")
if fileHandle ~= nil then
io.close(fileHandle)
return true, "No error"
else
if string.match(strError,"No such file or directory") then
return false, strError
else
return true, strError
end
end
end
if os_sep == "\\" then
-- These paths shoudl exists
path_exists = "E:\\Bureau"
path_exists_sep = "E:\\Bureau\\"
path_no = "E:\\thisfolderdoesntexist"
path_no_sep = "E:\\thisfolderdoesntexist\\"
else
-- These paths shoudl exists
path_exists = "/Users/jeremyda"
path_exists_sep = "/Users/jeremyda/"
path_no = "/Users/thisfolderdoesntexist"
path_no_sep = "/Users/thisfolderdoesntexist/"
end
t = {path_exists, path_exists_sep, path_no, path_no_sep}
out = {}
for i, path in ipairs( t ) do
local retval, err = FolderExists(path)
out[i] = i .. "\t" .. tostring(retval) .. "\t" .. err
end
reaper.CF_SetClipboard( table.concat(out, "\n" ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment