diff options
-rw-r--r-- | examples/pdf-mod-info.cc | 3 | ||||
-rw-r--r-- | libqpdf/Pl_StdioFile.cc | 7 | ||||
-rw-r--r-- | libtests/qtest/qutil/qutil.out | 4 | ||||
-rw-r--r-- | libtests/qutil.cc | 10 |
4 files changed, 10 insertions, 14 deletions
diff --git a/examples/pdf-mod-info.cc b/examples/pdf-mod-info.cc index e8defa32..8bd9f5d6 100644 --- a/examples/pdf-mod-info.cc +++ b/examples/pdf-mod-info.cc @@ -8,6 +8,7 @@ #include <iostream> #include <string.h> #include <stdlib.h> +#include <stdio.h> #ifdef _WIN32 #include <Windows.h> #include <direct.h> @@ -219,7 +220,7 @@ int main(int argc, char* argv[]) try { - (void) unlink(fl_out); + (void) remove(fl_out); QUtil::os_wrapper("rename " + fl_tmp + " " + std::string(fl_out), rename(fl_tmp.c_str(), fl_out)); } diff --git a/libqpdf/Pl_StdioFile.cc b/libqpdf/Pl_StdioFile.cc index 808177d0..4d3cba60 100644 --- a/libqpdf/Pl_StdioFile.cc +++ b/libqpdf/Pl_StdioFile.cc @@ -37,11 +37,8 @@ Pl_StdioFile::write(unsigned char* buf, size_t len) void Pl_StdioFile::finish() { - if (fileno(this->file) != -1) // XXXX - { - fflush(this->file); - } - else + if ((fflush(this->file) == -1) && + (errno == EBADF)) { throw std::logic_error( this->identifier + diff --git a/libtests/qtest/qutil/qutil.out b/libtests/qtest/qutil/qutil.out index c855e98e..737e4c72 100644 --- a/libtests/qtest/qutil/qutil.out +++ b/libtests/qtest/qutil/qutil.out @@ -12,8 +12,8 @@ one 7 compare okay ---- -before open -exception: open file: No such file or directory +before remove +exception: remove file: No such file or directory ---- before fopen exception: fopen file: No such file or directory diff --git a/libtests/qutil.cc b/libtests/qutil.cc index e293c374..8d9c2383 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -44,14 +44,12 @@ void string_conversion_test() void os_wrapper_test() { - int fd = -1; try { - std::cout << "before open" << std::endl; - fd = QUtil::os_wrapper("open file", - open("/this/file/does/not/exist", O_RDONLY)); - std::cout << "after open" << std::endl; - (void) close(fd); + std::cout << "before remove" << std::endl; + QUtil::os_wrapper("remove file", + remove("/this/file/does/not/exist")); + std::cout << "after remove" << std::endl; } catch (std::runtime_error& s) { |