Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 994 Bytes

File metadata and controls

46 lines (31 loc) · 994 Bytes

Filesystem

compiler flags: -lstdc++fs

source code from: http://www.modernescpp.com/index.php/c-17-more-details-about-the-library

#include <fstream>
#include <iostream>
#include <string>
#include <filesystem>

using namespace std;
namespace fs = std::filesystem;


int main()
{
	std::cout << "Current path: " << fs::current_path() << std::endl;
	std::string dir= "sandbox/a/b";
	fs::create_directories(dir);
	std::ofstream("sandbox/file1.txt");
	fs::path symPath= fs::current_path() /=  "sandbox";
	symPath /= "syma";
	fs::create_symlink("a", "symPath");
	 	
	std::cout << "fs::is_directory(dir): " << fs::is_directory(dir) << std::endl;
	std::cout << "fs::exists(symPath): "  << fs::exists(symPath) << std::endl;
	std::cout << "fs::symlink(symPath): " << fs::is_symlink(symPath) << std::endl;
	 	
	for(auto& p: fs::recursive_directory_iterator("sandbox"))
	{
		std::cout << p.path() << std::endl;
	}
	 
	
	return 0;
}