|
a/src/utils/copyfile.cpp |
|
b/src/utils/copyfile.cpp |
|
... |
|
... |
24 |
#include "safesysstat.h"
|
24 |
#include "safesysstat.h"
|
25 |
#include "safeunistd.h"
|
25 |
#include "safeunistd.h"
|
26 |
#ifndef _WIN32
|
26 |
#ifndef _WIN32
|
27 |
#include <sys/time.h>
|
27 |
#include <sys/time.h>
|
28 |
#include <utime.h>
|
28 |
#include <utime.h>
|
|
|
29 |
#define O_BINARY 0
|
29 |
#endif
|
30 |
#endif
|
30 |
|
31 |
|
31 |
#include <cstring>
|
32 |
#include <cstring>
|
32 |
|
33 |
|
33 |
#include "copyfile.h"
|
34 |
#include "copyfile.h"
|
|
... |
|
... |
41 |
{
|
42 |
{
|
42 |
int sfd = -1;
|
43 |
int sfd = -1;
|
43 |
int dfd = -1;
|
44 |
int dfd = -1;
|
44 |
bool ret = false;
|
45 |
bool ret = false;
|
45 |
char buf[CPBSIZ];
|
46 |
char buf[CPBSIZ];
|
46 |
int oflags = O_WRONLY|O_CREAT|O_TRUNC;
|
47 |
int oflags = O_WRONLY|O_CREAT|O_TRUNC|O_BINARY;
|
47 |
|
48 |
|
48 |
LOGDEB(("copyfile: %s to %s\n", src, dst));
|
49 |
LOGDEB(("copyfile: %s to %s\n", src, dst));
|
49 |
|
50 |
|
50 |
if ((sfd = ::open(src, O_RDONLY, 0)) < 0) {
|
51 |
if ((sfd = ::open(src, O_RDONLY, 0)) < 0) {
|
51 |
reason += string("open ") + src + ": " + strerror(errno);
|
52 |
reason += string("open ") + src + ": " + strerror(errno);
|
|
... |
|
... |
94 |
int flags)
|
95 |
int flags)
|
95 |
{
|
96 |
{
|
96 |
LOGDEB(("stringtofile:\n"));
|
97 |
LOGDEB(("stringtofile:\n"));
|
97 |
int dfd = -1;
|
98 |
int dfd = -1;
|
98 |
bool ret = false;
|
99 |
bool ret = false;
|
99 |
int oflags = O_WRONLY|O_CREAT|O_TRUNC;
|
100 |
int oflags = O_WRONLY|O_CREAT|O_TRUNC|O_BINARY;
|
100 |
|
101 |
|
101 |
LOGDEB(("stringtofile: %u bytes to %s\n", (unsigned int)dt.size(), dst));
|
102 |
LOGDEB(("stringtofile: %u bytes to %s\n", (unsigned int)dt.size(), dst));
|
102 |
|
103 |
|
103 |
if (flags & COPYFILE_EXCL) {
|
104 |
if (flags & COPYFILE_EXCL) {
|
104 |
oflags |= O_EXCL;
|
105 |
oflags |= O_EXCL;
|