Commit bc813c37 authored by Laszlo Csomor's avatar Laszlo Csomor

Address reviewer comments.

parent a118acc4
...@@ -1432,14 +1432,14 @@ CommandLineInterface::InterpretArgument(const std::string& name, ...@@ -1432,14 +1432,14 @@ CommandLineInterface::InterpretArgument(const std::string& name,
#if defined(_WIN32) #if defined(_WIN32)
// On Windows, the shell (typically cmd.exe) does not expand wildcards in // On Windows, the shell (typically cmd.exe) does not expand wildcards in
// file names (e.g. foo\*.proto), so we do it ourselves. // file names (e.g. foo\*.proto), so we do it ourselves.
switch (google::protobuf::internal::win32::expand_wildcards( switch (google::protobuf::io::win32::expand_wildcards(
value, value,
[this](const string& path) { [this](const string& path) {
this->input_files_.push_back(path); this->input_files_.push_back(path);
})) { })) {
case google::protobuf::internal::win32::ExpandWildcardsResult::kSuccess: case google::protobuf::io::win32::ExpandWildcardsResult::kSuccess:
break; break;
case google::protobuf::internal::win32::ExpandWildcardsResult::kErrorNoMatchingFile: case google::protobuf::io::win32::ExpandWildcardsResult::kErrorNoMatchingFile:
// Path does not exist, is not a file, or it's longer than MAX_PATH and // Path does not exist, is not a file, or it's longer than MAX_PATH and
// long path handling is disabled. // long path handling is disabled.
std::cerr << "Invalid file name pattern or missing input file \"" std::cerr << "Invalid file name pattern or missing input file \""
......
...@@ -362,7 +362,7 @@ wstring testonly_utf8_to_winpath(const char* path) { ...@@ -362,7 +362,7 @@ wstring testonly_utf8_to_winpath(const char* path) {
return as_windows_path(path, &wpath) ? wpath : wstring(); return as_windows_path(path, &wpath) ? wpath : wstring();
} }
bool expand_wildcards( int expand_wildcards(
const string& path, std::function<void(const string&)> consume) { const string& path, std::function<void(const string&)> consume) {
if (path.find_first_of("*?") == string::npos) { if (path.find_first_of("*?") == string::npos) {
// There are no wildcards in the path, we don't need to expand it. // There are no wildcards in the path, we don't need to expand it.
......
...@@ -92,12 +92,8 @@ struct ExpandWildcardsResult { ...@@ -92,12 +92,8 @@ struct ExpandWildcardsResult {
// in the last path segment. This function passes all matching file names to // in the last path segment. This function passes all matching file names to
// `consume`. The resulting paths may not be absolute nor normalized. // `consume`. The resulting paths may not be absolute nor normalized.
// //
// The function returns true if the path did not contain any wildcards (in // The function returns a value from `ExpandWildcardsResult`.
// which case the path may or may not exist), or the path did contain wildcards LIBPROTOBUF_EXPORT int expand_wildcards(
// and it matched at least one file.
// The function returns false if the path contained wildcards but it did not
// match any files.
LIBPROTOBUF_EXPORT bool expand_wildcards(
const std::string& path, std::function<void(const std::string&)> consume); const std::string& path, std::function<void(const std::string&)> consume);
namespace strings { namespace strings {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment