Skip to content

Commit

Permalink
more meaningful message printed in case ~/.rr file doesn't simply exi…
Browse files Browse the repository at this point in the history
…st. fixes rr-debugger#1583
  • Loading branch information
szborows committed Jan 13, 2016
1 parent 1f74d79 commit c6ffbe4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/TraceStream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ static TraceStream::Substream operator++(TraceStream::Substream& s) {
return s;
}

static bool file_exists(const string& file) {
struct stat dummy;
return !file.empty() && stat(file.c_str(), &dummy) == 0
&& S_ISREG(dummy.st_mode);
}

static bool dir_exists(const string& dir) {
struct stat dummy;
return !dir.empty() && stat(dir.c_str(), &dummy) == 0;
return !dir.empty() && stat(dir.c_str(), &dummy) == 0
&& S_ISDIR(dummy.st_mode);
}

static string default_rr_trace_dir() {
Expand Down Expand Up @@ -592,6 +599,14 @@ TraceReader::TraceReader(const string& dir)
}

string path = version_path();
if (!file_exists(path)) {
fprintf(
stderr,
"rr: warning: No traces have been recorded so far.\n"
"\n");
exit(EX_DATAERR);
}

fstream vfile(path.c_str(), fstream::in);
if (!vfile.good()) {
fprintf(
Expand Down

0 comments on commit c6ffbe4

Please sign in to comment.