Using the full uppercase file name to create a hash might seem quicker at first, but unless I'm missing something, it could actually work out slower since the entire file name has to be converted before performing a character by character comparison. On the other hand, a mismatch may occur in the first few characters meaning that fewer character conversions are required by not creating a hash. Of course, I am assuming that the search is only performed once. If you are attempting to add or extract many files there may be a speed advantage by pre-calculating a hash but I would still opt for code simplicity since the compression or decompression operation is likely to be much slower than the search operation anyway. To give you some idea of the speed of Windows string comparison operations, I can sort all the files in the Windows\System32 directory almost instantaneously - even using the quicksort algo, that's a heck of a lot string comparisons. (I'm using a 3.5 year old Dell Inspiron, albeit with a dual-core AMD Turion CPU.) I use the following functions. I don't think they are suitable as they stand for your purposes but they might be helpful. -- James Turner const LANG_INVARIANT = $7F; LOCALE_INVARIANT = (SORT_DEFAULT shl 16) or (SUBLANG_NEUTRAL shl 10) or LANG_INVARIANT; LOCALE_INVARIANT_BEFORE_XP = (SORT_DEFAULT shl 16) or (SUBLANG_ENGLISH_US shl 10) or LANG_ENGLISH; { http://msdn2.microsoft.com/en-us/library/aa468951.aspx } { The following code sample demonstrates the preferred way of performing a locale-independent test on Windows 2000. } { } { CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), ... } function _CompareStr(LOCALE:LCID; s1,s2:pChar; Max:integer):integer; { Set Max = -1 to scan to end of shorter string } { nil and #0 are treated equally } begin result := 0; if s1 = s2 then exit; if s1 = nil then if s2^ = #0 then exit { return zero } else result := -1 else if s2 = nil then if s1^ = #0 then exit { return zero } else result := +1 else begin if LOCALE = 0 then begin if PlatformXP then LOCALE := LOCALE_INVARIANT else LOCALE := LOCALE_INVARIANT_BEFORE_XP; end; result := CompareString(LOCALE,NORM_IGNORECASE,s1,Max,s2,Max) - 2; end; end; function FileNameEqual(const s1,s2:string):Boolean; begin result := _CompareStr(0,pointer(s1),pointer(s2),-1) = 0; end; R Peters wrote: > To speed up searching for non-wild file names I pre-calculate the CRC of the > uppercase name to use as a hash key for comparison - if the keys don't match > there is no point trying to compare the names themselves (comparing the > names also uses uppercase - oh the stupid initial decision for Windows to > ignore case for file/domain names). > Of course doing it my way it will not correctly upcase characters that that > version of Windows does not handle but the rest won't handle it either - > early Windows only had just enough Unicode support to convert the MBCS to > Unicode for the file handling and that only for installed code-pages. > Russell Peters > > On Wed, Sep 29, 2010 at 9:41 PM, James Turner <james.d.h.turner@xxxxxxxxxxxx > >> wrote: >> > > >>> From memory I only use it to 'standardize' characters to before >>> calculating crc which is the reason I decided against a full >>> library with its enormous Unicode tables. >>> >> I still don't understand how or why this code is being used - CRC means >> cyclic redundancy check to me. >> >> -- James Turner >> ----------- >> To unsubscribe from this list, send an empty e-mail >> message to: >> delphizip-request@xxxxxxxxxxxxx >> and put the word unsubscribe in the subject. >> >> > > > ----------- > To unsubscribe from this list, send an empty e-mail > message to: > delphizip-request@xxxxxxxxxxxxx > and put the word unsubscribe in the subject. > > ----------- To unsubscribe from this list, send an empty e-mail message to: delphizip-request@xxxxxxxxxxxxx and put the word unsubscribe in the subject.