We are apologize for the inconvenience but you need to download
more modern browser in order to be able to browse our page

Download Safari
Download Safari
Download Chrome
Download Chrome
Download Firefox
Download Firefox
Download IE 10+
Download IE 10+

Cpp filesystem库 枚举文件初体验

#include <iostream>
#include <filesystem>
#include <string>
namespace fs = std::experimental::filesystem;

void enum_file(const std::string & path, std::function<void(const fs::path &)> handler) {
	for (auto & p : fs::directory_iterator(path)) {
		std::cout << p << std::endl;
		if (fs::is_directory(p.status()))
		{
			enum_file(p.path().string(), handler);
		}
		else
		{
			handler(p.path());
		}
	}
}

用上了filesystem(我家VS2015当时还不是Cpp17,自然是在experiment的namespace里面啦)

文件操作突然变得异常简单。顺带用了lambda,用起来也是特别舒服。

(完了感觉自己再也不会写c了怎么办OAO)