Browse Source

Merge branch 'autogen-empty-source-file-fix' into release-3.10

There is no corresponding merge request because this fix was
cherry-picked specifically for CMake 3.10.
pull/320/head
Brad King 8 years ago
parent
commit
760c6c08a5
  1. 6
      Source/cmQtAutoGenerators.cxx

6
Source/cmQtAutoGenerators.cxx

@ -80,6 +80,7 @@ static bool ReadFile(std::string& content, std::string const& filename,
std::size_t const length = cmSystemTools::FileLength(filename);
cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary));
if (ifs) {
if (length > 0) {
content.resize(length);
ifs.read(&content.front(), content.size());
if (ifs) {
@ -90,6 +91,11 @@ static bool ReadFile(std::string& content, std::string const& filename,
error->append("Reading from the file failed.");
}
}
} else {
// Readable but empty file
content.clear();
success = true;
}
} else if (error != nullptr) {
error->append("Opening the file for reading failed.");
}

Loading…
Cancel
Save