Wildcard rules in Delphi Zip Keep in mind that the DLL code is from Unix. The Unix wildcard rules are used. Most people think the wildcard rules in Unix make more sense than those in Windows. They are based on Regular Expressions, which abound in Unix. Wildcards are allowed in directory names - why not? This is very handy! Period is NOT special in Unix filenames (unless it is the first char), so "*.*" will match any name that has a period in it Similarly, "*E*" will match any name that has an E in it (by the way Unix is case sensitive) In Unix, "*.*" will NOT match all filenames - it will only match filenames containing a period (many files in Unix do not have extensions at all). Since all MS-DOS/Windows filenames have a period in them nobody ever noticed this! In Unix, a simple "*" will match all filenames except those beginning with a period. A filename (or dirname) beginning with a period is said to be "hidden" in Unix. It won't be shown in a simple directory listing. "ls -l" long list of files, excludes names beginning with period "ls -al" long list of "all" files, including those that begin with period "ls -l .??*" List only hidden file/directory names In the last case above, you can NOT say: "ls -l .*" This is because you will also be match the name of your current and parent directory. As in MS-DOS, there are 2 special dirnames that begin with period . = current directory .. = parent directory MS-DOS made a mistake when they said this will skip everything up to the period in the filename: "file*nov20.doc" We obviously wanted to show all files beginning with "file" and ending with the 9 characters "nov20.doc". Unix follows the "correct" rules for regular expressions in this case. Remember - a period is just another letter unless the name starts with a period. In MS-DOS/Windows we can't start with a period so this is not an issue for us. Most of your examples are right, but I'm not sure about this one: "two\file.ext" will match "two\file.ext" and "any\two\file.ext" It looks to me like the name must being with "two", but I haven't tested this assumption. Unix also supports brackets in wildcards to mean "any one of these": ls -l [aAbB]name.ext The above will match any file beginning with an upper or lower case "a" or "b", and ending in "name.ext". This is cool, but I don't think I did this in the DLLs - the code was nasty and I think I took it out (it was a long time ago and my memory is not so good). ---- Now for the "big issue" - I have taken the lazy approach by keeping the Unix wildcard rules. In order to be politically correct we should probably support the Windows rules instead of the Unix rules. I propose a new property to set which rules the wildcard expansion uses. The programmer could select either Windows or Unix rules. I think we should default it to Windows rules. Or, maybe we should just switch everything to Windows rules only? I'm afraid of breaking existing apps, so I'd perfer to have a property to select the rules. Anyone can feel free to tell us what you think about this... Eric -----Original Message----- From: Russell Peters [mailto:russellpeters@xxxxxxxxxxx] Sent: Thursday, March 21, 2002 5:18 PM To: delphizip@xxxxxxxxxxxxx Subject: [delphizip] Apologies to Eric and questions I must apologise - I my thoughts on Unzip's match were most uncomplimentary. I now know why you used recursion, though you seem to have a problem with the path/name boundary. Do (should) you allow wildcards in paths? Should embedded wildcards be allowed ie should "file*nov20.doc" match "filetry1nov20.doc" but not "filetry1.doc" (this is how it works at present but is it desirable - nothing else allows it - in windows at least) Now for how I think you wanted paths to match (have to lead up to it) *.* - will match any file/ext on any path \*.* - will match any file/ext in base dir sub\*.* - will match any file/ext in any subdir "sub" on any path ie "two\file.ext" will match "two\file.ext" and "any\two\file.ext" \sub\*.* - will match any file in "sub" from base ie "\sub" Checking extensions (this is how it works now) string "file.ext1.ext2.ext3" "*.*" matches "*.ext3" matches "*.ext2.ext3" matches "*.ext1" does not match please clarify these if you will so I can redo it - Russell Peters