Lazarus

Free Pascal => General => Topic started by: sigipa on March 29, 2017, 08:18:38 am

Title: Reading a directory
Post by: sigipa on March 29, 2017, 08:18:38 am
Hello All,

I'm new to pascal, so please forgive my ignorance. I've been searching for a function to read a directory. I'm aware of FindFirst, but I don't need any kind of search testing or the overhead of that. Is there a function that will just read a directory ala libc opendir/readdir?

Thanks,
-S
Title: Re: Reading a directory
Post by: balazsszekely on March 29, 2017, 08:22:51 am
Quote
Hello All,

I'm new to pascal, so please forgive my ignorance. I've been searching for a function to read a directory. I'm aware of FindFirst, but I don't need any kind of search testing or the overhead of that. Is there a function that will just read a directory ala libc opendir/readdir?

Hi sigipa,

FindAllFiles from fileutil perhaps?
http://wiki.freepascal.org/FindAllFiles
Title: Re: Reading a directory
Post by: sigipa on March 29, 2017, 08:32:07 am
Hi,

I saw that, but I fear that it will be doing some unnecessary testing on the filter (or lack thereof). I'll take a look at the source to see if that is an issue. I appreciate the pointer.

Thanks,
-S
Title: Re: Reading a directory
Post by: marcov on March 29, 2017, 10:05:53 am
findfirst/next on unix is roughly opendir/readdir + stat per file.

readdir is pages of code so a simple test on an integer value to check if it is a dir is not measurable. The stat thing might be measurable though, but that is the price of portability.
TinyPortal © 2005-2018