Old 02-14-2018, 08:02 AM   #1
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,062
Default ReaScript EnumerateFiles function Cache files list ?

Hi,


It seeùs that the EnumerateFiles cache file list for each subfolder.

This means that if you os.rename so file, you will not see the file list change, even if you recall EnumerateFiles .

Here is a sample code:

Quote:
function EnumerateFiles( folder )
local files = {}
local i = 0
repeat
local retval = reaper.EnumerateFiles( folder, i )
table.insert(files, retval)
i = i + 1
until not retval
return files
end

path = "E:\\Bureau\\Test\"

files_a = EnumerateFiles( path )
retval, message = os.rename(path .. "1.txt", path .. "4.txt")
files__b = EnumerateFiles( path )
And here is the result:



But note that the files do change, it is just the EnumerateFiles which stay the same.

Here is test code from cfillion;



I would have expect EnumerateFiles to NOT cache the result, and let the coder cache it by himself and use virtual folder structure if he want (surely faster), at least as an optional argument, as it is a bit unexpected (and undocumented) behavior.

Thanks !
X-Raym is offline   Reply With Quote
Old 02-14-2018, 06:12 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,062
Default

According to cfillion test, the cache last 17 ticks (approx 500ms).
X-Raym 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 05:03 PM.


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