[fpc-pascal] findfirst wildcards...
Ralf Quint
freedos.la at gmail.com
Wed Dec 3 21:52:08 CET 2014
On 12/3/2014 12:27 PM, Bart wrote:
> On 12/3/14, Ralf Quint <freedos.la at gmail.com> wrote:
>
>> On any DOS based OS (that includes OS/2 and Windows), the "?" wildcard
>> character will find any character, including no character at all in that
>> position. So in your example, t?.txt will find t.txt and tx.txt but not
>> txy.txt. It will not return any filename longer than your search mask,
>> but return shorter filenames. This is (should be) a functionality of the
>> underlying system calls.
> Windows.FindFirstFile however treats ? as exactly 1 character AFAIK.
> And is I'm not mistake this was also the case with TP in the old days.
>
I do not have a working DOS on my Windows 8.1 laptop here right now, but
as long as I can remember, the "?" as always a match for "one or none",
allowing for a shorter filename as the filemask to be returned. The only
exception that comes to my mind though is a the combination of "??*.txt"
for example, which would return all filenames at least two characters long,
A quick test in a Windows 8.1 command prompt:
Directory of C:\Users\Ralf\x
12/03/2014 12:50 PM <DIR> .
12/03/2014 12:50 PM <DIR> ..
12/03/2014 12:49 PM 3 a.txt
12/03/2014 12:49 PM 3 aa.txt
12/03/2014 12:49 PM 3 aaa.txt
12/03/2014 12:50 PM 3 b.txt
12/03/2014 12:50 PM 3 bb.txt
12/03/2014 12:50 PM 3 bbb.txt
12/03/2014 12:50 PM 3 c.txt
12/03/2014 12:50 PM 3 cc.txt
12/03/2014 12:50 PM 3 ccc.txt
9 File(s) 27 bytes
2 Dir(s) 324,408,578,048 bytes free
C:\Users\Ralf\x>dir ?.txt
Volume in drive C is TI10673200G
Volume Serial Number is 5E9D-3D3F
Directory of C:\Users\Ralf\x
12/03/2014 12:49 PM 3 a.txt
12/03/2014 12:50 PM 3 b.txt
12/03/2014 12:50 PM 3 c.txt
3 File(s) 9 bytes
0 Dir(s) 324,408,578,048 bytes free
C:\Users\Ralf\x>dir ??.txt
Volume in drive C is TI10673200G
Volume Serial Number is 5E9D-3D3F
Directory of C:\Users\Ralf\x
12/03/2014 12:49 PM 3 a.txt
12/03/2014 12:49 PM 3 aa.txt
12/03/2014 12:50 PM 3 b.txt
12/03/2014 12:50 PM 3 bb.txt
12/03/2014 12:50 PM 3 c.txt
12/03/2014 12:50 PM 3 cc.txt
6 File(s) 18 bytes
0 Dir(s) 324,408,573,952 bytes free
C:\Users\Ralf\x>
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
More information about the fpc-pascal
mailing list