Bug in Windows's FindFirstFile() function?

前端 未结 2 1865
逝去的感伤
逝去的感伤 2020-12-21 06:01

Why does calling FindFirstFile with the pattern *.* match a name like Windows?

Edit: I guess I can also guess wha

相关标签:
2条回答
  • 2020-12-21 06:27

    *.* matches everything in the target directory.

    This is because *. matches up to the final period; if there is no period in the name then that name is treated as if it ended in a period; so *. matches only names beginning with a period and names containing no period (.afile / adirname) if you add a * on the end for *.* then it also matches beyond the final period so includes file names containing a period, this covers all possible file names.

    0 讨论(0)
  • 2020-12-21 06:29

    In the blog post 'How did wildcards work in MS-DOS?' Raymond Chen describes how the original DOS wildcard matching was implemented. At the end of the post he points out how *.* is handled as a special case in the Win32 wildcard matching algorithm.

    A quote from the post

    For example, if your pattern ends in .*, the .* is ignored. Without this rule, the pattern *.* would match only files that contained a dot, which would break probably 90% of all the batch files on the planet, as well as everybody's muscle memory, since everybody running Windows NT 3.1 grew up in a world where *.* meant all files.

    0 讨论(0)
提交回复
热议问题