Sign in Join

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

Mailing lists / fpc-pascal / 2017-10

Finding long file names

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

James Richters
I'm trying to use findfirst()/findnext to obtain a list of files.  Here's my code:
Searchfile:=Tap_Drive+Tap_Path+'\'+Tap_SubDirectory+'\*.TAP';
If FindFirst(Searchfile, FAAnyfile-FAHidden, FileDirInfo)=0 then
..

It finds most files, even ones with really long file names, however it can't find files with periods in the file name, So it will find:
This is a TEST.Tap

But it will not find:
This.is.a.TEST.tap

If I change my search string to:
Searchfile:=Tap_Drive+Tap_Path+'\'+Tap_SubDirectory+'\*.*';

Then it DOES find the files with more than one period in them... along with everything else.

I could filter them out myself I suppose, but that seems to defeat the way findfirst is supposed to work.

Any ideas how to make this work? Is there a better method to use than findfirst() ?

I notice that if I use Extractfileext() with This.is.a.TEST.tap it correctly returns '.tap' as the extension. Maybe findfirst is an obsolete way of listing the files? Or maybe it just never got fixed to handle valid files with more than one period?

Any thoughts on this?

James

Michael Van Canneyt
to James Richters
James Richters wrote 22 lines
I'm trying to use findfirst()/findnext to obtain a list of files. Here's my code: Searchfile:=Tap_Drive+Tap_Path+'\'+Tap_SubDirectory+'\*.TAP'; If FindFirst(Searchfile, FAAnyfile-FAHidden, FileDirInfo)=0 then .. It finds most files, even ones with really long file names, however it can't find files with periods in the file name, So it will find: This is a TEST.Tap But it will not find: This.is.a.TEST.tap If I change my search string to: Searchfile:=Tap_Drive+Tap_Path+'\'+Tap_SubDirectory+'\*.*'; Then it DOES find the files with more than one period in them... along with everything else. I could filter them out myself I suppose, but that seems to defeat the way findfirst is supposed to work. Any ideas how to make this work? Is there a better method to use than findfirst() ? I notice that if I use Extractfileext() with This.is.a.TEST.tap it correctly returns '.tap' as the extension. Maybe findfirst is an obsolete way of listing the files? Or maybe it just never got fixed to handle valid files with more than one period?

Findfirst is definitely the way.

If this is on windows, then you've probably found a bug in findfirst/findnext. Strange that this would go unnoticed for so long.

Michael.

Sven Barth
to James Richters: I'm trying to use findfirst()/findnext to obtain a list of files. Here's my code:…

Am 05.10.2017 01:49 schrieb "James Richters" <

: I'm trying to use findfirst()/findnext to obtain a list of files. Here's

my code:

Show quoted text 5 lines
Searchfile:=Tap_Drive+Tap_Path+'\'+Tap_SubDirectory+'\*.TAP'; If FindFirst(Searchfile, FAAnyfile-FAHidden, FileDirInfo)=0 then .. It finds most files, even ones with really long file names, however it

can't find files with periods in the file name,

Show quoted text 10 lines
So it will find: This is a TEST.Tap But it will not find: This.is.a.TEST.tap If I change my search string to: Searchfile:=Tap_Drive+Tap_Path+'\'+Tap_SubDirectory+'\*.*'; Then it DOES find the files with more than one period in them... along

with everything else.

I could filter them out myself I suppose, but that seems to defeat the

way findfirst is supposed to work.

Any ideas how to make this work? Is there a better method to use than

findfirst() ?

I notice that if I use Extractfileext() with This.is.a.TEST.tap it

correctly returns '.tap' as the extension. Maybe findfirst is an obsolete way of listing the files? Or maybe it just never got fixed to handle valid files with more than one period?

Any thoughts on this?

I can't reproduce it here. Would you please provide a self contained, small example plus information about the OS, filesystem and compiler as well as a list of filenames to test with?

Regards,
Sven

James Richters
to Sven Barth
I can't reproduce it here. Would you please provide a self contained, small example plus information about the OS, filesystem and compiler as well as a list of filenames to test with?

Well, here’s some good news, I was cutting and pasting my code to make a self contained example and I found my problem, but to my surprise, my sample program was working fine.. I had to do a lot of digging, but I finally found the problem… There was some old code left over from the dos days to identify files by extension that wasn’t working right with more than one ‘.’ I modernized the function and it’s working great now! I thought I took care of all the Dos limitations over a year ago, but I missed this one. Thanks for the help, knowing it was working for someone else got me to the problem.

James