Sign in Join

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

Mailing lists / fpc-devel / 2005-09

FindFirst broken due to ExpandFileName bug?

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Tony Maro

I just tried to use FindFirst to get a listing of files in a directory. I passed FindFirst the following:

    if FindFirst('/home/tony/test/*',faAnyFile, Res) < 0 then begin

It never would return any results. Then I noticed that FindFirst calls:

GlobSearchRec^.Path:=ExpandFileName(ExtractFilePath(Path));

So I ran:

    ExpandFileName(ExtractFilePath('/home/tony/test/*'));

And I got:

/home/tony/LazarusFiles/testapp/"/home/tony/test/

You can see it concatenated my application path, a quote, and the path I entered.

-Tony

Reply by email

Michael Van Canneyt
to Tony Maro
Tony Maro wrote 16 lines
I just tried to use FindFirst to get a listing of files in a directory. I passed FindFirst the following: if FindFirst('/home/tony/test/*',faAnyFile, Res) < 0 then begin It never would return any results. Then I noticed that FindFirst calls: GlobSearchRec^.Path:=ExpandFileName(ExtractFilePath(Path)); So I ran: ExpandFileName(ExtractFilePath('/home/tony/test/*')); And I got: /home/tony/LazarusFiles/testapp/"/home/tony/test/

Do you still have this bug ?
The most recent compiler/rtl gives the following, which is IMHO correct:

----------------------------------------------------------------------- home: >ppc386 testp.pp
home: >./testp
/home/michael/
home: >cd fpc
home: >~/testp
/home/michael/
home: >cat ~/testp.pp
program testp;

uses sysutils;
begin
  Writeln(ExpandFileName(ExtractFilePath('/home/michael/*')));
end.
home: >
-----------------------------------------------------------------------

Michael.

Reply by email

Tony Maro
to Michael Van Canneyt
Michael Van Canneyt wrote 28 lines
On Mon, 12 Sep 2005, Tony Maro wrote: >I just tried to use FindFirst to get a listing of files in a directory. I >passed FindFirst the following: > > if FindFirst('/home/tony/test/*',faAnyFile, Res) < 0 then begin > >It never would return any results. Then I noticed that FindFirst calls: > >GlobSearchRec^.Path:=ExpandFileName(ExtractFilePath(Path)); > >So I ran: > > ExpandFileName(ExtractFilePath('/home/tony/test/*')); > >And I got: > > /home/tony/LazarusFiles/testapp/"/home/tony/test/ > > Do you still have this bug ? The most recent compiler/rtl gives the following, which is IMHO correct:

I'm running:
Free Pascal Compiler version 2.0.1 [2005/07/20] for i386

Reply by email

Michael Van Canneyt
to Tony Maro
Tony Maro wrote 34 lines
Michael Van Canneyt wrote: > On Mon, 12 Sep 2005, Tony Maro wrote: > > > > > I just tried to use FindFirst to get a listing of files in a > > directory. I > > passed FindFirst the following: > > > > if FindFirst('/home/tony/test/*',faAnyFile, Res) < 0 then begin > > > > It never would return any results. Then I noticed that FindFirst > > calls: > > > > GlobSearchRec^.Path:=ExpandFileName(ExtractFilePath(Path)); > > > > So I ran: > > > > ExpandFileName(ExtractFilePath('/home/tony/test/*')); > > > > And I got: > > > > /home/tony/LazarusFiles/testapp/"/home/tony/test/ > > > > > > Do you still have this bug ? The most recent compiler/rtl gives the > following, which is IMHO correct: > > > I'm running: Free Pascal Compiler version 2.0.1 [2005/07/20] for i386

This is a snapshot compiler, please use the official compiler if you can.

If you use snapshots, use only the latest possible. The development compiler is not guaranteed bug free, as you can see. The current development compiler has no problem with your code, so that is the one you should use...

The fixbranch compiler also no longer has the problem:

home: >compiler/ppc386 -l -Furtl/units/i386-linux ~/testp Free Pascal Compiler version 2.0.1 [2005/09/02] for i386 Copyright (c) 1993-2005 by Florian Klaempfl
home: >~/testp
/home/michael/

Maybe you can update that one (not to the 2.1.1 branch)

Michael.

Reply by email

Tony Maro
to Michael Van Canneyt
Michael Van Canneyt wrote 17 lines
This is a snapshot compiler, please use the official compiler if you can. If you use snapshots, use only the latest possible. The development compiler is not guaranteed bug free, as you can see. The current development compiler has no problem with your code, so that is the one you should use... The fixbranch compiler also no longer has the problem: home: >compiler/ppc386 -l -Furtl/units/i386-linux ~/testp Free Pascal Compiler version 2.0.1 [2005/09/02] for i386 Copyright (c) 1993-2005 by Florian Klaempfl home: >~/testp /home/michael/ Maybe you can update that one (not to the 2.1.1 branch)

Thanks - I guess then that confirms that it _was_ an issue (which is why I posted this here rather than run do a bug report.) I forget exactly why I ended up grabbing the snapshot that day, but there was some reason I'm sure. I'm not one to update unless I have to or I get several months behind ;-)

-Tony

Reply by email