mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Use portable versions of some UNIX-specific calls
Remove needless calls to open, close, and fileno; call remove instead of unlink.
This commit is contained in:
parent
6b9297882e
commit
66c3c8fdf7
@ -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));
|
||||
}
|
||||
|
@ -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 +
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user