Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-05

FindFirst FindNext

8 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

I thought the file attributes are ignored under linux, but apparently they are not.
Is it normal, that FindNext returns a file twice?

uses
  SysUtils;
var
  Info: TSearchRec;
begin
  if FindFirst('*',faDirectory,Info)=0 then
  begin
    repeat
      writeln(Info.Name);
    until FindNext(Info)0;
  end;
  FindClose(Info);
end;

With faAnyFile every file is listed only once.

Mattias

Graeme Geldenhuys
to Mattias Gaertner
Mattias Gaertner wrote
I thought the file attributes are ignored under linux, but apparently they are not. Is it normal, that FindNext returns a file twice?

Would that explain why the TFileListBox component and Lazarus's "File Browser" add-on shows double files under my Linux system.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Graeme Geldenhuys
to Mattias Gaertner: I thought the file attributes are ignored under linux, but apparently they are not. Is it…
Mattias Gaertner wrote
I thought the file attributes are ignored under linux, but apparently they are not. Is it normal, that FindNext returns a file twice?

And sometimes even more than twice as the following output shows (using the code you posted). This is the exact behaviour I get with TFileListBox and "File Browser" lazarus add-on.

======================
/tmp $ ./testfindnext
libgksu-B6XiRP
libgksu-B6XiRP
libgksu-B6XiRP
testfindnext.o
project1.rc
unit1.ppu
unit1.ppu
project1.manifest
vmc-conn.lock
ssh-oviXuy7045
orbit-graemeg

======================

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Mattias Gaertner
to Graeme Geldenhuys: On Fri, May 1, 2009 at 11:55 AM, Mattias Gaertner Would that explain why the TFileListBox…
Show quoted text 8 lines
On Fri, May 1, 2009 at 11:55 AM, Mattias Gaertner wrote: > I thought the file attributes are ignored under linux, but > apparently they are not. > Is it normal, that FindNext returns a file twice? Would that explain why the TFileListBox component and Lazarus's "File Browser" add-on shows double files under my Linux system.

Yes.

It seems it is buggy under OS X too.
I guess, this must be added to the wiki pages about cross platform issues.

Mattias

Graeme Geldenhuys
to Mattias Gaertner
Mattias Gaertner wrote
Yes.

Ah. And using faAnyFile and then testing .Attr for faDirectory is one way to overcome the problem.

It seems it is buggy under OS X too. I guess, this must be added to the wiki pages about cross platform issues.

I'm using FPC 2.2.5 but noticed this issue some time ago, but could never pinpoint it. It might be good to report it on the wiki, but it should definitely be reported as a bug in FPC Mantis as well. Kylix doesn't have this issue.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Jonas Maebe
to Mattias Gaertner: I thought the file attributes are ignored under linux, but apparently they are not. Is it…
Mattias Gaertner wrote
I thought the file attributes are ignored under linux, but apparently they are not.

They are currently ignored if you do not use wildcards, otherwise they are used. I'm tested a fix to change that so that they are always used.

Is it normal, that FindNext returns a file twice?

No.

With faAnyFile every file is listed only once.

I'm testing a fix for this as well.

Jonas

Mattias Gaertner
to Jonas Maebe
Show quoted text 8 lines
On 01 May 2009, at 11:55, Mattias Gaertner wrote: > I thought the file attributes are ignored under linux, but > apparently they are not. They are currently ignored if you do not use wildcards, otherwise they are used. I'm tested a fix to change that so that they are always used.

Thanks. I hope this will not slow down things. I have some programs that scan directories with millions of files. (Don't ask)

Show quoted text 7 lines
> Is it normal, that FindNext returns a file twice? No. > With faAnyFile every file is listed only once. I'm testing a fix for this as well.

No need to fix faAnyFile. I like the only once. ;)

Mattias

Jonas Maebe
to Mattias Gaertner
Mattias Gaertner wrote 14 lines
On Fri, 1 May 2009 17:43:48 +0200 Jonas Maebe wrote: > On 01 May 2009, at 11:55, Mattias Gaertner wrote: > >> I thought the file attributes are ignored under linux, but >> apparently they are not. > > They are currently ignored if you do not use wildcards, otherwise > they are used. I'm tested a fix to change that so that they are > always used. Thanks. I hope this will not slow down things. I have some programs that scan directories with millions of files. (Don't ask)

It's fixed in r13074. It will slow down things slightly if you don't use wildcards, since some memory is now allocated and released for the non-wildcard searches (whereas this previously was not the case).

Jonas