From 240ba0118aa9f394545f8b487198d036b1fd0c2a Mon Sep 17 00:00:00 2001 From: Joshua Beck Date: Mon, 26 Sep 2011 04:04:16 -0500 Subject: [PATCH] Added support for reading file lists from stdin --- cli/cmdlineparser.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 034b61046..264ad7424 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -45,11 +45,21 @@ static void AddFilesToList(const std::string& FileList, std::vector // xml is a bonus then, since we can easily extend it // we need a good parser then -> suggestion : TinyXml // drawback : creates a dependency - std::ifstream Files(FileList.c_str()); + std::istream *Files; + std::ifstream Infile; + if (FileList.compare("-") == 0) // read from stdin + { + Files = &std::cin; + } + else + { + Infile.open(FileList.c_str()); + Files = &Infile; + } if (Files) { std::string FileName; - while (std::getline(Files, FileName)) // next line + while (std::getline(*Files, FileName)) // next line { if (!FileName.empty()) {