27 lines
841 B
C++
27 lines
841 B
C++
|
#include "filetape.h"
|
||
|
#include "tape_config.h"
|
||
|
#include "tape_util.h"
|
||
|
#include <iostream>
|
||
|
|
||
|
int main(int argc, char *argv[]) {
|
||
|
CmdArgs cmd = parse_command_line(argc, argv);
|
||
|
if (cmd.version) {
|
||
|
std::cout << VERSION_MSG << std::endl;
|
||
|
return 0;
|
||
|
}
|
||
|
if (cmd.help) {
|
||
|
std::cerr << HELP_MSG << std::endl;
|
||
|
return 0;
|
||
|
}
|
||
|
tape::FileTape input(cmd.input_file_name, cmd.settings);
|
||
|
tape::FileTape output(input, cmd.output_file_name, cmd.settings);
|
||
|
// tmp tape factory that captures cmd.settings from local scope
|
||
|
tape::TempTapeFactory factory =
|
||
|
[&](size_t cells) -> std::unique_ptr<tape::Tape> {
|
||
|
return std::make_unique<tape::FileTape>(
|
||
|
tape::FileTape(cells, cmd.settings));
|
||
|
};
|
||
|
tape::external_sort(input, output, factory, cmd.memory_limit);
|
||
|
return 0;
|
||
|
}
|