ensure path exists
This commit is contained in:
parent
eeb7f77911
commit
cf024f1c4c
3 changed files with 9 additions and 8 deletions
3
main.cpp
3
main.cpp
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
void generate_file(int N, const std::string& filename)
|
||||
{
|
||||
std::filesystem::path dirPath = std::filesystem::path(filename).parent_path();
|
||||
std::filesystem::create_directories(dirPath);
|
||||
|
||||
std::ofstream out_stream(filename);
|
||||
Writer output(out_stream);
|
||||
|
||||
|
|
|
|||
10
makefile
10
makefile
|
|
@ -6,22 +6,16 @@ build/main: main.cpp sort.cpp config.hpp buffer.hpp reader.hpp writer.hpp build
|
|||
build:
|
||||
mkdir -p build
|
||||
|
||||
build/run:
|
||||
mkdir -p build/run
|
||||
|
||||
build/run/tmp:
|
||||
mkdir -p build/run/tmp
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
generate: build/run/1.in
|
||||
|
||||
# actually should depend on build/main and build/run, but that will trigger it every recompile, and i don't need that
|
||||
build/run/1.in: build/run/tmp
|
||||
build/run/1.in:
|
||||
build/main -g -o build/run/1.in
|
||||
|
||||
run: build/main build/run/1.in build/run/tmp
|
||||
run: build/main build/run/1.in
|
||||
build/main -i build/run/1.in -d build/run/tmp
|
||||
|
||||
debug: build/main tests/1.in
|
||||
|
|
|
|||
4
sort.cpp
4
sort.cpp
|
|
@ -20,6 +20,9 @@ size_t read_chunk(Reader& reader, SubBuffer& buff)
|
|||
|
||||
void write_to_file(const std::string& filename, SubBuffer& buff, size_t n)
|
||||
{
|
||||
std::filesystem::path dirPath = std::filesystem::path(filename).parent_path();
|
||||
std::filesystem::create_directories(dirPath);
|
||||
|
||||
std::ofstream out_stream(filename);
|
||||
Writer output_writer(out_stream);
|
||||
for (size_t j = 0; j < n; j++) {
|
||||
|
|
@ -46,6 +49,7 @@ void create_initial_runs(const std::string& input_filename, const std::string& d
|
|||
int sort_file(const Configuration& opts)
|
||||
{
|
||||
Buffer main_buffer(opts.n * opts.b);
|
||||
|
||||
create_initial_runs(opts.input_file, opts.directory, main_buffer);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue