tjysdsg / tan

A programming language for fun

Home Page:https://tjysdsg.github.io/tan/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

check file attributes before reading

todo opened this issue · comments

commented

// TODO: check file attributes before reading
_filename = filename;
std::ifstream ifs(filename);
// read the whole file at once
std::string content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
// count the number of lines


This issue was generated by todo based on a TODO comment in 12ad011 when #6 was merged. cc @tjysdsg.

Since ifstream will throw if it cannot open a file, there is no need to check beforehand.