forked from OSchip/llvm-project
Fix rdar://5843510 don't assert and die when an invalid output
file is specified, print a happy little error message. llvm-svn: 49518
This commit is contained in:
parent
90bde997b3
commit
47fb9efa5d
|
@ -60,8 +60,14 @@ static void InitOutputBuffer(const std::string& Output) {
|
||||||
if (!Output.size() || Output == "-")
|
if (!Output.size() || Output == "-")
|
||||||
OutputFILE = stdout;
|
OutputFILE = stdout;
|
||||||
else {
|
else {
|
||||||
OutputFILE = fopen(Output.c_str(), "w+");
|
|
||||||
OutputFilename = Output;
|
OutputFilename = Output;
|
||||||
|
OutputFILE = fopen(Output.c_str(), "w+");
|
||||||
|
|
||||||
|
if (OutputFILE == 0) {
|
||||||
|
fprintf(stderr, "Error opening output file '%s'.\n", Output.c_str());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(OutputFILE && "failed to open output file");
|
assert(OutputFILE && "failed to open output file");
|
||||||
|
@ -73,11 +79,13 @@ static void InitOutputBuffer(const std::string& Output) {
|
||||||
if (!Output.size() || Output == "-")
|
if (!Output.size() || Output == "-")
|
||||||
OutputFD = STDOUT_FILENO;
|
OutputFD = STDOUT_FILENO;
|
||||||
else {
|
else {
|
||||||
OutputFD = open(Output.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0644);
|
|
||||||
OutputFilename = Output;
|
OutputFilename = Output;
|
||||||
|
OutputFD = open(Output.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0644);
|
||||||
|
if (OutputFD < 0) {
|
||||||
|
fprintf(stderr, "Error opening output file '%s'.\n", Output.c_str());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(OutputFD >= 0 && "failed to open output file");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue