erius
8f18f9ef8f
Moved ftsort sources to bin/ftsort Moved tape_config.h into bin/ftsort Implemented command line parsing for ftsort in tape_config.cpp ftsort binary is in working state
26 lines
841 B
C++
26 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;
|
|
}
|