Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@ int main(int argc, char* argv[]){

time_t t1 = time(NULL);

bool supportEvaluation = !opt.inputFromSTDIN && opt.in1!="/dev/stdin";
bool supportEvaluation = !opt.inputFromSTDIN && opt.in1!="/dev/stdin"
&& is_regular_file(opt.in1)
&& (opt.in2.empty() || is_regular_file(opt.in2));

Evaluator eva(&opt);
if(supportEvaluation) {
Expand Down
9 changes: 9 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ inline bool is_directory(const string& path)
return isdir;
}

// check if a path is a regular file (seekable), not a pipe/FIFO/device
inline bool is_regular_file(const string& path)
{
struct stat status;
if( stat( path.c_str(), &status ) != 0 )
return false;
return S_ISREG( status.st_mode );
}

inline void check_file_valid(const string& s) {
if(!file_exists(s)){
cerr << "ERROR: file '" << s << "' doesn't exist, quit now" << endl;
Expand Down
Loading