できない
#include <iostream> #include <string> #include <sstream> #include <iomanip> #include <functional> #include <experimental/filesystem> #include <algorithm> #include <cassert> #include <map> #include <fstream> #include <random> #include "Radix.h" namespace fs = std::experimental::filesystem; int main() { std::string root = "./testDir"; fs::create_directories(root); std::random_device rnd; std::mt19937 mt(rnd()); Radix r; // make sample datas std::vector<std::pair<std::string, std::string>> sample_datas; for (int i = 0; i < 1000; i++) { // create old_filenames std::string o = std::to_string(mt()); // create new_filename std::string n = r.to((unsigned long long)std::stoll(o), 16); sample_datas.emplace_back(std::pair<std::string, std::string>(o, n)); } // create sample files for (auto& data : sample_datas) { std::string filename = root + "/" + data.first; std::ofstream{ filename }; } // rename oldfilename -> newfilename for (auto& data : sample_datas) { std::string o = root + "/" + data.first; std::string n = root + "/" + data.second; fs::rename(o, n); } std::cout << "done." << std::endl; getchar(); return 0; }
windowsコマンドプロンプトで大量のダミーファイルを作成する方法
for /L %i in (1, 1, 1000) do fsutil file createnew E:\testfile_%i.dat 1048576
python3で簡単ウェブサーバ起動
python3 -m http.server 8000
iniの値をmapで管理
#include <Windows.h> #include <iostream> #include <array> #include <vector> #include <string> #include <map> #include <sstream> int main() { const std::string filePath = ".\\test.ini"; std::array<char, 1024> buf; // vectorだと怒られる ::GetPrivateProfileSection("SectionA", &buf.front(), static_cast<DWORD>(buf.size()), filePath.c_str()); bool is_key = true; std::map<std::string, std::string> m; std::string k; std::string v; for (const auto& c : buf) { if (c == '=') { is_key = false; continue; } if (c == '\0') { m.insert({ k, v }); is_key = true; k.clear(); v.clear(); continue; } if (is_key) k.push_back(c); else v.push_back(c); } for (auto x : m) std::cout << "key=" << x.first << " value=" << x.second << std::endl; system("pause"); return 0; }