Changeset 5065

Show
Ignore:
Timestamp:
12/03/07 19:26:06 (9 months ago)
Author:
morris
Message:

Redo to do a full CFString comparison on OS X, for better case comparison support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wired/trunk/wired/files.c

    r5064 r5065  
    635635                /* get file type */ 
    636636                type = wd_files_type_with_stat(filepath, &sb); 
    637                 name = wd_files_path_with_decomposed_cstring(p->fts_name); 
    638                  
    639                 if(wi_string_contains_string(name, query, WI_STRING_CASE_INSENSITIVE)) { 
     637                name = wi_string_with_cstring(p->fts_name); 
     638                 
     639                if(wd_files_name_matches_query(name, query, wi_make_range(0, wi_string_length(name)))) { 
    640640                        /* matched, get size */ 
    641641                        switch(type) { 
     
    732732                        range.length = index; 
    733733                         
    734                         if(wi_string_index_of_string_in_range(string, query, WI_STRING_CASE_INSENSITIVE, range) != WI_NOT_FOUND) { 
     734                        if(wd_files_name_matches_query(string, query, range)) { 
    735735                                if(account->files) { 
    736736                                        pathrange.location = index + 1; 
     
    878878        WI_FTS                                  *fts = NULL; 
    879879        WI_FTSENT                               *p; 
    880         wi_string_t                             *filepath, *virtualpath, *name, *string; 
     880        wi_string_t                             *filepath, *virtualpath, *string; 
    881881        wi_number_t                             *number; 
    882882        wi_file_offset_t                size; 
     
    958958                /* get file type & size */ 
    959959                type = wd_files_type_with_stat(filepath, &sb); 
    960                 name = wd_files_path_with_decomposed_cstring(p->fts_name); 
    961960 
    962961                switch(type) { 
     
    980979                 
    981980                wi_file_write(file, WI_STR("%#s%c%#s%#@%c%u%c%llu%c%#@%c%#@\n"), 
    982                                           name,                                       WD_FIELD_SEPARATOR, 
     981                                          p->fts_name,                        WD_FIELD_SEPARATOR, 
    983982                                          pathprefix, 
    984983                                          virtualpath,                  WD_FIELD_SEPARATOR, 
     
    13251324 
    13261325 
    1327 wi_string_t * wd_files_path_with_decomposed_cstring(const char *cstring) { 
    1328         wi_string_t                             *path; 
    1329          
     1326wi_boolean_t wd_files_name_matches_query(wi_string_t *name, wi_string_t *query, wi_range_t range) { 
    13301327#ifdef HAVE_CORESERVICES_CORESERVICES_H 
    1331         CFMutableStringRef              string; 
    1332         char                                    buffer[WI_PATH_SIZE]; 
    1333          
    1334         string = CFStringCreateMutable(NULL, 0); 
    1335         CFStringAppendCString(string, cstring, kCFStringEncodingUTF8); 
    1336         CFStringNormalize(string, kCFStringNormalizationFormC); 
    1337         CFStringGetCString(string, buffer, sizeof(buffer), kCFStringEncodingUTF8); 
    1338         path = wi_string_with_cstring(buffer); 
    1339         CFRelease(string); 
     1328        CFMutableStringRef              nameString; 
     1329        CFStringRef                             queryString; 
     1330        wi_boolean_t                    matches; 
     1331         
     1332        nameString = CFStringCreateMutable(NULL, 0); 
     1333        CFStringAppendCString(nameString, wi_string_cstring(name), kCFStringEncodingUTF8); 
     1334        CFStringNormalize(nameString, kCFStringNormalizationFormC); 
     1335         
     1336        queryString = CFStringCreateWithCString(NULL, wi_string_cstring(query), kCFStringEncodingUTF8); 
     1337         
     1338        matches = CFStringFindWithOptions(nameString, queryString, CFRangeMake(range.location, range.length),  kCFCompareCaseInsensitive, NULL); 
     1339 
     1340        CFRelease(nameString); 
     1341        CFRelease(queryString); 
     1342         
     1343        return matches; 
    13401344#else 
    1341         path = wi_string_with_cstring(cstring); 
     1345        return (wi_string_index_of_string_in_range(name, query, WI_STRING_CASE_INSENSITIVE, range) != WI_NOT_FOUND); 
    13421346#endif 
    1343          
    1344         return path; 
    13451347} 
    13461348 
  • wired/trunk/wired/files.h

    r5064 r5065  
    7373wi_boolean_t                                                    wd_files_path_is_dropbox(wi_string_t *); 
    7474wi_string_t *                                                   wd_files_real_path(wi_string_t *); 
    75 wi_string_t *                                                  wd_files_path_with_decomposed_cstring(const char *); 
     75wi_boolean_t                                                   wd_files_name_matches_query(wi_string_t *, wi_string_t *, wi_range_t); 
    7676 
    7777