Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: tools/crashpad_database_util.cc

Issue 1023943003: crashpad_database_util: Accept --new-report=- to read a new report from standard input (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@crashpad_database_util_new_report
Patch Set: Rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/crashpad_database_util.cc
diff --git a/tools/crashpad_database_util.cc b/tools/crashpad_database_util.cc
index cd5a2195bd5b2146a1abb28ee0b3dabfea8c329b..47b00818f391c1d98711c45663aefd3353582292 100644
--- a/tools/crashpad_database_util.cc
+++ b/tools/crashpad_database_util.cc
@@ -56,7 +56,7 @@ void Usage(const std::string& me) {
" --set-uploads-enabled=BOOL enable or disable uploads\n"
" --set-last-upload-attempt-time=TIME\n"
" set the last-upload-attempt time to TIME\n"
-" --new-report=PATH submit a new report at PATH\n"
+" --new-report=PATH submit a new report at PATH, or - for stdin\n"
" --utc show and set UTC times instead of local\n"
" --help display this help and exit\n"
" --version output version information and exit\n",
@@ -518,9 +518,17 @@ int DatabaseUtilMain(int argc, char* argv[]) {
}
for (const base::FilePath new_report_path : options.new_report_paths) {
- FileReader file_reader;
- if (!file_reader.Open(new_report_path)) {
- return EXIT_FAILURE;
+ scoped_ptr<FileReaderInterface> file_reader;
+
+ if (new_report_path.value() == "-") {
+ file_reader.reset(new WeakStdioFileReader(stdin));
+ } else {
+ scoped_ptr<FileReader> file_path_reader(new FileReader());
+ if (!file_path_reader->Open(new_report_path)) {
+ return EXIT_FAILURE;
+ }
+
+ file_reader = file_path_reader.Pass();
}
CrashReportDatabase::NewReport* new_report;
@@ -535,7 +543,7 @@ int DatabaseUtilMain(int argc, char* argv[]) {
char buf[4096];
ssize_t read_result;
- while ((read_result = file_reader.Read(buf, sizeof(buf))) > 0) {
+ while ((read_result = file_reader->Read(buf, sizeof(buf))) > 0) {
if (!LoggingWriteFile(new_report->handle, buf, read_result)) {
return EXIT_FAILURE;
}
@@ -552,6 +560,13 @@ int DatabaseUtilMain(int argc, char* argv[]) {
return EXIT_FAILURE;
}
+ file_reader.reset();
+ if (new_report_path.value() == "-") {
+ if (fclose(stdin) == EOF) {
+ STDIO_PLOG(ERROR) << "fclose";
+ }
+ }
+
const char* prefix = (show_operations > 1) ? "New report ID: " : "";
printf("%s%s\n", prefix, uuid.ToString().c_str());
}
« no previous file with comments | « tools/crashpad_database_util.ad ('k') | util/file/file_io.h » ('j') | util/file/file_reader.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698