Changeset 5066
- Timestamp:
- 12/04/07 14:32:49 (7 months ago)
- Files:
-
- wired/trunk/wired/files.c (modified) (5 diffs)
- wired/trunk/wired/files.h (modified) (1 diff)
- wired/trunk/wired/server.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wired/trunk/wired/files.c
r5065 r5066 637 637 name = wi_string_with_cstring(p->fts_name); 638 638 639 if(wd_files_name_matches_query(name, query, wi_make_range(0, wi_string_length(name)))) {639 if(wd_files_name_matches_query(name, query, false)) { 640 640 /* matched, get size */ 641 641 switch(type) { … … 727 727 break; 728 728 729 index = wi_string_index_of_char(string, WD_FIELD_SEPARATOR, 0); 730 731 if(index != WI_NOT_FOUND) { 732 range.length = index; 729 if(wd_files_name_matches_query(string, query, true)) { 730 index = wi_string_index_of_char(string, WD_FIELD_SEPARATOR, 0); 733 731 734 if(wd_files_name_matches_query(string, query, range)) { 735 if(account->files) { 736 pathrange.location = index + 1; 737 pathrange.length = wi_string_length(string) - pathrange.location; 738 739 if(wi_string_index_of_string_in_range(string, account->files, WI_STRING_CASE_INSENSITIVE, pathrange) == pathrange.location) { 740 wi_string_delete_characters_to_index(string, index + pathlength + 1); 741 742 wd_reply(420, WI_STR("%@"), string); 743 } 744 } else { 745 wi_string_delete_characters_to_index(string, index + 1); 732 if(account->files) { 733 pathrange.location = index + 1; 734 pathrange.length = wi_string_length(string) - pathrange.location; 735 736 if(wi_string_index_of_string_in_range(string, account->files, WI_STRING_CASE_INSENSITIVE, pathrange) == pathrange.location) { 737 wi_string_delete_characters_to_index(string, index + pathlength + 1); 746 738 747 739 wd_reply(420, WI_STR("%@"), string); 748 740 } 741 } else { 742 wi_string_delete_characters_to_index(string, index + 1); 743 744 wd_reply(420, WI_STR("%@"), string); 749 745 } 750 746 } … … 1324 1320 1325 1321 1326 wi_boolean_t wd_files_name_matches_query(wi_string_t *name, wi_string_t *query, wi_ range_t range) {1322 wi_boolean_t wd_files_name_matches_query(wi_string_t *name, wi_string_t *query, wi_boolean_t index) { 1327 1323 #ifdef HAVE_CORESERVICES_CORESERVICES_H 1328 1324 CFMutableStringRef nameString; 1329 1325 CFStringRef queryString; 1326 CFRange range; 1330 1327 wi_boolean_t matches; 1331 1328 … … 1336 1333 queryString = CFStringCreateWithCString(NULL, wi_string_cstring(query), kCFStringEncodingUTF8); 1337 1334 1338 matches = CFStringFindWithOptions(nameString, queryString, CFRangeMake(range.location, range.length), kCFCompareCaseInsensitive, NULL); 1335 if(index) 1336 range = CFRangeMake(0, CFStringFind(nameString, CFSTR(WD_FIELD_SEPARATOR_STR), 0).location); 1337 else 1338 range = CFRangeMake(0, CFStringGetLength(nameString)); 1339 1340 if(range.length == kCFNotFound) 1341 matches = false; 1342 else 1343 matches = CFStringFindWithOptions(nameString, queryString, range, kCFCompareCaseInsensitive, NULL); 1339 1344 1340 1345 CFRelease(nameString); … … 1343 1348 return matches; 1344 1349 #else 1345 return (wi_string_index_of_string_in_range(name, query, WI_STRING_CASE_INSENSITIVE, range) != WI_NOT_FOUND); 1350 wi_range_t range; 1351 1352 if(index) 1353 range = wi_make_range(0, wi_string_index_of_char(name, WD_FIELD_SEPARATOR, 0)); 1354 else 1355 range = wi_make_range(0, wi_string_length(name)); 1356 1357 if(range.length == WI_NOT_FOUND) 1358 return false; 1359 else 1360 return (wi_string_index_of_string_in_range(name, query, WI_STRING_CASE_INSENSITIVE, range) != WI_NOT_FOUND); 1346 1361 #endif 1347 1362 } wired/trunk/wired/files.h
r5065 r5066 73 73 wi_boolean_t wd_files_path_is_dropbox(wi_string_t *); 74 74 wi_string_t * wd_files_real_path(wi_string_t *); 75 wi_boolean_t wd_files_name_matches_query(wi_string_t *, wi_string_t *, wi_ range_t);75 wi_boolean_t wd_files_name_matches_query(wi_string_t *, wi_string_t *, wi_boolean_t); 76 76 77 77 wired/trunk/wired/server.h
r4842 r5066 41 41 #define WD_MESSAGE_SEPARATOR_STR "\4" 42 42 #define WD_FIELD_SEPARATOR '\34' 43 #define WD_FIELD_SEPARATOR_STR "\34" 43 44 #define WD_GROUP_SEPARATOR '\35' 44 45 #define WD_RECORD_SEPARATOR '\36'
