lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hey Joshua,

There is a way to read the directory in just 2-3 kernel calls. (A little more if the directory is bigger, and provided buffer is not enough). I can't tell whether it's faster, but it's out there.


FYI: It's doing more that it's supposed to do, for example two times calling

if(!GetFileInformationByHandleEx(h, (FILE_INFO_BY_HANDLE_CLASS)i, buffer1, sizeof(buffer1)) || !GetFileInformationByHandleEx(h, (FILE_INFO_BY_HANDLE_CLASS)i, buffer2, sizeof(buffer2)))

but this was just to explore how the functions were behaving, and whether they were filling the buffer to the end.

Only one call is needed there.

Dimiter 'malkia' Stanev.

On 12/16/2011 9:20 AM, Joshua Jensen wrote:
----- Original Message -----
From: Joshua Jensen
Date: 12/16/2011 3:00 AM
----- Original Message -----
From: Xavier Wang
Date: 12/16/2011 2:46 AM
I have try to find a lua module that acts like GNU find, it can
enumerate files in a directory, and makes some filter on it:

find "." :name ".svn" :prune()

or something like it.
The filefind module [1] may do what you want [2] [3]:

require 'filefind'

-- Just files, excluding .svn directories.
for entry in filefind.glob('**@-.svn/') do

Also, just to add this, the filefind module is very high performance,
especially on Windows. LuaFileSystem does not collect file information
from the FindFirstFile/FindNextFile iteration calls. It asks separately
for the file stats. It has been my experience that this is VERY costly
on Windows.