mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-26 03:48:42 +00:00
feat(judger): add "x bytes omitted" info
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
cea0e82db8
commit
74127afe25
@ -133,6 +133,9 @@ string file_preview(const string &name, const int &len = 100) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct stat stat_buf;
|
||||||
|
stat(name.c_str(), &stat_buf);
|
||||||
|
|
||||||
string res = "";
|
string res = "";
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
int c;
|
int c;
|
||||||
@ -145,8 +148,9 @@ string file_preview(const string &name, const int &len = 100) {
|
|||||||
res += c;
|
res += c;
|
||||||
}
|
}
|
||||||
if ((int)res.size() > len + 3) {
|
if ((int)res.size() > len + 3) {
|
||||||
|
int omitted = (int)stat_buf.st_size - len;
|
||||||
res.resize(len);
|
res.resize(len);
|
||||||
res += "...";
|
res += "\n\n(" + to_string(omitted) + " bytes omitted)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -130,6 +130,9 @@ string file_preview(const string &name, const int &len = 100) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct stat stat_buf;
|
||||||
|
stat(name.c_str(), &stat_buf);
|
||||||
|
|
||||||
string res = "";
|
string res = "";
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
int c;
|
int c;
|
||||||
@ -142,8 +145,9 @@ string file_preview(const string &name, const int &len = 100) {
|
|||||||
res += c;
|
res += c;
|
||||||
}
|
}
|
||||||
if ((int)res.size() > len + 3) {
|
if ((int)res.size() > len + 3) {
|
||||||
|
int omitted = (int)stat_buf.st_size - len;
|
||||||
res.resize(len);
|
res.resize(len);
|
||||||
res += "...";
|
res += "\n\n(" + to_string(omitted) + " bytes omitted)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
Loading…
Reference in New Issue
Block a user