MCPcopy Create free account
hub / github.com/davisking/dlib / add_files

Function add_files

tools/htmlify/htmlify.cpp:477–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475// -------------------------------------------------------------------------------------------------
476
477void 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 {

Callers 1

mainFunction · 0.85

Calls 11

errorClass · 0.85
create_directoryFunction · 0.50
get_filesMethod · 0.45
resetMethod · 0.45
move_nextMethod · 0.45
nameMethod · 0.45
sizeMethod · 0.45
strMethod · 0.45
addMethod · 0.45
clearMethod · 0.45
get_dirsMethod · 0.45

Tested by

no test coverage detected