#include <ctime>
#include <random>
#include <fstream>
#include <iostream>

#include <bobcat/filesystem>
#include <bobcat/exception>

using namespace std;
using namespace FBB;

char ch[] = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
mt19937 mt{ static_cast<size_t>(time(0)) };


int main(int argc, char **argv)
{
    if (argc == 1)
    {
        cerr << "1st arg: base name, 2nd arg: #ext.\n";
        return 1;
    }

    string fname{ argv[1] };
    fname += '.';
    
    size_t nExt = stoul(argv[2]);

    for (
        size_t begin = fname.length(), end = begin + nExt;
            begin != end;
                ++begin
    )
        fname.push_back(ch[mt() % (size(ch) - 1)]);


    cout << fname << ", " << nExt << " ext. chars\n";

    if (not FileSystem{ fname }.exists())
        Exception::protection(fname, 0600);
}
