| 475 | // ------------------------------------------------------------------------------------------------- |
| 476 | |
| 477 | void add_files ( |
| 478 | const directory& dir, |
| 479 | const std::string& out_dir, |
| 480 | map_string_to_string& file_map, |
| 481 | bool flatten, |
| 482 | bool cat, |
| 483 | const set_of_string& filter, |
| 484 | unsigned long search_depth, |
| 485 | unsigned long cur_depth |
| 486 | ) |
| 487 | { |
| 488 | const char separator = directory::get_separator(); |
| 489 | |
| 490 | queue_of_files files; |
| 491 | queue_of_dirs dirs; |
| 492 | |
| 493 | dir.get_files(files); |
| 494 | |
| 495 | // look though all the files in the current directory and add the |
| 496 | // ones that match the filter to file_map |
| 497 | string name, ext, in_file, out_file; |
| 498 | files.reset(); |
| 499 | while (files.move_next()) |
| 500 | { |
| 501 | name = files.element().name(); |
| 502 | string::size_type pos = name.find_last_of('.'); |
| 503 | if (pos != string::npos && filter.is_member(name.substr(pos+1))) |
| 504 | { |
| 505 | in_file = files.element().full_name(); |
| 506 | |
| 507 | if (flatten) |
| 508 | { |
| 509 | pos = in_file.find_last_of(separator); |
| 510 | } |
| 511 | else |
| 512 | { |
| 513 | // figure out how much of the file's path we need to keep |
| 514 | // for the output file name |
| 515 | pos = in_file.size(); |
| 516 | for (unsigned long i = 0; i <= cur_depth && pos != string::npos; ++i) |
| 517 | { |
| 518 | pos = in_file.find_last_of(separator,pos-1); |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | if (pos != string::npos) |
| 523 | { |
| 524 | out_file = out_dir + in_file.substr(pos+1) + ".html"; |
| 525 | } |
| 526 | else |
| 527 | { |
| 528 | out_file = out_dir + in_file + ".html"; |
| 529 | } |
| 530 | |
| 531 | if (file_map.is_in_domain(out_file)) |
| 532 | { |
| 533 | if (file_map[out_file] != in_file) |
| 534 | { |