Changeset 5150
- Timestamp:
- 01/05/08 01:01:52 (8 months ago)
- Files:
-
- wired/trunk/wired/files.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wired/trunk/wired/files.c
r5066 r5150 77 77 static wi_boolean_t wd_files_read_comment(wi_file_t *, wi_string_t **, wi_string_t **); 78 78 79 static WI_FTS * wd_files_fts_open(wi_string_t *, wi_boolean_t , wi_boolean_t);79 static WI_FTS * wd_files_fts_open(wi_string_t *, wi_boolean_t); 80 80 static wd_files_fts_action_t wd_files_fts_action(WI_FTSENT *, int *); 81 81 static int wd_files_fts_namecmp(const WI_FTSENT **, const WI_FTSENT **); … … 146 146 } 147 147 148 fts = wd_files_fts_open(realpath, true , true);148 fts = wd_files_fts_open(realpath, true); 149 149 150 150 if(!fts) { … … 188 188 189 189 /* skip if we're not recursive */ 190 if(!recursive && p->fts_level > 1) {190 if(!recursive) 191 191 wi_fts_set(fts, p, WI_FTS_SKIP); 192 193 continue;194 }195 192 196 193 /* create real path */ … … 284 281 285 282 static wi_file_offset_t wd_files_count_path(wi_string_t *path, wi_boolean_t interactive) { 286 WI_FTS *fts; 287 WI_FTSENT *p; 283 wi_string_t *filepath; 284 DIR *dir; 285 struct dirent de, *dep; 288 286 wi_file_offset_t count = 0; 289 wd_files_fts_action_t action; 290 int error; 291 292 fts = wd_files_fts_open(path, false, false); 293 294 if(!fts) { 287 288 dir = opendir(wi_string_cstring(path)); 289 290 if(!dir) { 295 291 wi_log_warn(WI_STR("Could not open %@: %s"), 296 292 path, strerror(errno)); … … 298 294 if(interactive) 299 295 wd_reply_error(); 300 296 301 297 return 0; 302 298 } 303 299 304 while((p = wi_fts_read(fts))) { 305 /* skip item? */ 306 action = wd_files_fts_action(p, &error); 307 308 switch(action) { 309 case WD_FILES_FTS_KEEP: 310 break; 311 312 case WD_FILES_FTS_IGNORE: 313 case WD_FILES_FTS_ERROR: 300 while(readdir_r(dir, &de, &dep) == 0 && dep) { 301 /* skip . files */ 302 if(dep->d_name[0] == '.') { 303 if(!wd_settings.showdotfiles) 314 304 continue; 315 break;316 317 case WD_FILES_FTS_SKIP:318 wi_fts_set(fts, p, WI_FTS_SKIP);319 305 } 306 307 /* skip regular expression */ 308 if(wd_settings.ignoreexpression) { 309 if(wi_regexp_match_cstring(wd_settings.ignoreexpression, dep->d_name)) 320 310 continue; 321 break;322 }323 324 /* skip recursion */325 if(p->fts_level > 1) {326 wi_fts_set(fts, p, WI_FTS_SKIP); 327 328 continue;311 } 312 313 /* skip mac invisibles */ 314 if(!wd_settings.showinvisiblefiles) { 315 filepath = wi_string_by_appending_format(path, WI_STR("/%s"), dep->d_name); 316 317 if(wi_file_is_invisible(filepath)) 318 continue; 329 319 } 330 320 331 321 count++; 332 322 } 333 334 wi_fts_close(fts);323 324 closedir(dir); 335 325 336 326 return count; … … 570 560 wi_boolean_t alias, recurse; 571 561 572 fts = wd_files_fts_open(path, false , true);562 fts = wd_files_fts_open(path, false); 573 563 574 564 if(!fts) { … … 893 883 } 894 884 895 fts = wd_files_fts_open(path, false , true);885 fts = wd_files_fts_open(path, false); 896 886 897 887 if(!fts) { … … 1366 1356 #pragma mark - 1367 1357 1368 static WI_FTS * wd_files_fts_open(wi_string_t *path, wi_boolean_t sorted , wi_boolean_t logical) {1358 static WI_FTS * wd_files_fts_open(wi_string_t *path, wi_boolean_t sorted) { 1369 1359 WI_FTS *fts; 1370 1360 char *paths[2]; … … 1374 1364 paths[1] = NULL; 1375 1365 1376 options = WI_FTS_NOSTAT; 1377 1378 if(logical) 1379 options |= WI_FTS_LOGICAL; 1380 else 1381 options |= WI_FTS_PHYSICAL | WI_FTS_COMFOLLOW; 1382 1366 options = WI_FTS_NOSTAT | WI_FTS_LOGICAL; 1383 1367 errno = 0; 1384 1368 fts = wi_fts_open(paths, options, sorted ? wd_files_fts_namecmp : NULL);
