What is the fastest way to create and zip nested files in c++?

  7zip, c++, nested

I created this utility to create nesting files.
For instance, you have one file:
NEST-0.TXT that contains "INTENTIONS.TXT" 10 times.
and NEST-1.TXT that contains "NEST-0.TXT" 10 times.

So by the time you get to NEST-100.TXT, you have created
essentially a Googol, or 10^100 total paths.

Here is my code. I would like to optimize it to be able to
create larger sets. On my Rasperry Pi 4, doing 1000 files
at 10,000 references to the previous file, each,
this gives about 1000 ^ 10000 total combinations.

Here is my code. How can I make it multithreaded or possibly faster? It creates
the ZIP on the fly, deleting each TXT as it’s created, so that it doesn’t take up too much space.

  #include <cstdio>
  #include <fstream>
  #include <iostream>
  #include <stdio.h>
  #include <string>

  using namespace std;

  int main() {
    std::string num_files="10", num_repetitions="1000", create_filename, archive_7zip;
    char command[128];
    char filename[] = "NEST-FULLPOWER.ZIP";

    int repnum, filenum, current_filenum;
    std::fstream myfile;

    if (stoi(num_files) > 1) {
      for (filenum = 1; filenum <= stoi(num_files); filenum++) {
    create_filename = "NEST-" + std::to_string(filenum) + ".TXT";
    myfile.open(create_filename, ios::out);

    for (repnum = 1; repnum <= stoi(num_repetitions); repnum++) {
      myfile << "NEST-" + std::to_string(filenum - 1) + ".TXTrn";
    }
    myfile.close();

      cout << "Adding File # " << std::to_string(filenum) << " / " << num_files << "rn";
      snprintf(command, 128,
               "7z a -mx=9 NEST-FULLPOWER.ZIP NEST-%d.TXT >> logfile.txt", filenum);
      system(command);
      snprintf(command, 128, "rm NEST-%d.TXT", filenum);
      system(command);
      }
    }

    return 0;
  }

Source: Windows Questions C++

LEAVE A COMMENT