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

Function add_files

tools/htmlify/htmlify.cpp:579–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577// -------------------------------------------------------------------------------------------------
578
579void add_files (
580 const directory& dir,
581 const std::string& out_dir,
582 map_string_to_string& file_map,
583 bool flatten,
584 bool cat,
585 const set_of_string& filter,
586 unsigned long search_depth,
587 const std::set<std::filesystem::path>& explicit_inputs,
588 unsigned long cur_depth
589)
590{
591 const char separator = directory::get_separator();
592
593 queue_of_files files;
594 queue_of_dirs dirs;
595
596 dir.get_files(files);
597
598 // look though all the files in the current directory and add the
599 // ones that match the filter to file_map
600 string name, ext, in_file, out_file;
601 files.reset();
602 while (files.move_next())
603 {
604 name = files.element().name();
605 string::size_type pos = name.find_last_of('.');
606 if (pos != string::npos && filter.is_member(name.substr(pos+1)))
607 {
608 in_file = files.element().full_name();
609 // Explicit command-line files keep their requested output location.
610 if (explicit_inputs.count(fs::weakly_canonical(in_file)))
611 continue;
612
613 if (flatten)
614 {
615 pos = in_file.find_last_of(separator);
616 }
617 else
618 {
619 // figure out how much of the file's path we need to keep
620 // for the output file name
621 pos = in_file.size();
622 for (unsigned long i = 0; i <= cur_depth && pos != string::npos; ++i)
623 {
624 pos = in_file.find_last_of(separator,pos-1);
625 }
626 }
627
628 if (pos != string::npos)
629 {
630 out_file = out_dir + in_file.substr(pos+1) + ".html";
631 }
632 else
633 {
634 out_file = out_dir + in_file + ".html";
635 }
636

Callers 1

mainFunction · 0.85

Calls 12

errorClass · 0.85
countMethod · 0.80
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