diff --git a/judger/uoj_judger/include/uoj_judger.h b/judger/uoj_judger/include/uoj_judger.h index ac4c6f0..daf825e 100644 --- a/judger/uoj_judger/include/uoj_judger.h +++ b/judger/uoj_judger/include/uoj_judger.h @@ -133,6 +133,9 @@ string file_preview(const string &name, const int &len = 100) { return ""; } + struct stat stat_buf; + stat(name.c_str(), &stat_buf); + string res = ""; if (len == -1) { int c; @@ -145,8 +148,9 @@ string file_preview(const string &name, const int &len = 100) { res += c; } if ((int)res.size() > len + 3) { + int omitted = (int)stat_buf.st_size - len; res.resize(len); - res += "..."; + res += "\n\n(" + to_string(omitted) + " bytes omitted)"; } } fclose(f); diff --git a/judger/uoj_judger/include/uoj_judger_v2.h b/judger/uoj_judger/include/uoj_judger_v2.h index cc1222b..d804a4f 100644 --- a/judger/uoj_judger/include/uoj_judger_v2.h +++ b/judger/uoj_judger/include/uoj_judger_v2.h @@ -130,6 +130,9 @@ string file_preview(const string &name, const int &len = 100) { return ""; } + struct stat stat_buf; + stat(name.c_str(), &stat_buf); + string res = ""; if (len == -1) { int c; @@ -142,8 +145,9 @@ string file_preview(const string &name, const int &len = 100) { res += c; } if ((int)res.size() > len + 3) { + int omitted = (int)stat_buf.st_size - len; res.resize(len); - res += "..."; + res += "\n\n(" + to_string(omitted) + " bytes omitted)"; } } fclose(f);