mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Clean windows a little
svn:r2757
This commit is contained in:
@@ -11,10 +11,7 @@
|
||||
#include "compat.h"
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#include <io.h>
|
||||
#include <process.h>
|
||||
#include <direct.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNAME
|
||||
#include <sys/utsname.h>
|
||||
|
||||
+8
-10
@@ -18,12 +18,9 @@
|
||||
#include "log.h"
|
||||
#include "crypto.h"
|
||||
|
||||
/* XXXX probably some of these are unneeded. find out which. */
|
||||
#ifdef MS_WINDOWS
|
||||
#include <io.h>
|
||||
#include <process.h>
|
||||
#include <direct.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
@@ -90,6 +87,9 @@
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#ifndef O_TEXT
|
||||
#define O_TEXT 0
|
||||
#endif
|
||||
|
||||
/* =====
|
||||
* Memory management
|
||||
@@ -809,7 +809,7 @@ int write_bytes_to_file(const char *fname, const char *str, size_t len,
|
||||
log(LOG_WARN, "Filename %s.tmp too long (>1024 chars)", fname);
|
||||
return -1;
|
||||
}
|
||||
if ((fd = open(tempname, O_WRONLY|O_CREAT|O_TRUNC|(bin?O_BINARY:0), 0600))
|
||||
if ((fd = open(tempname, O_WRONLY|O_CREAT|O_TRUNC|(bin?O_BINARY:O_TEXT), 0600))
|
||||
< 0) {
|
||||
log(LOG_WARN, "Couldn't open %s for writing: %s", tempname,
|
||||
strerror(errno));
|
||||
@@ -848,7 +848,7 @@ char *read_file_to_str(const char *filename, int bin) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fd = open(filename,O_RDONLY|(bin?O_BINARY:0),0);
|
||||
fd = open(filename,O_RDONLY|(bin?O_BINARY:O_TEXT),0);
|
||||
if (fd<0) {
|
||||
log_fn(LOG_WARN,"Could not open %s.",filename);
|
||||
return NULL;
|
||||
@@ -877,11 +877,9 @@ char *read_file_to_str(const char *filename, int bin) {
|
||||
}
|
||||
#ifdef MS_WINDOWS
|
||||
if (!bin && strchr(string, '\r')) {
|
||||
if (strchr(string, '\r')) {
|
||||
log_fn(LOG_DEBUG, "We didn't convert CRLF to LF as well as we hoped when reading %s. Coping.",
|
||||
filename);
|
||||
tor_strstrip(string, "\r");
|
||||
}
|
||||
log_fn(LOG_DEBUG, "We didn't convert CRLF to LF as well as we hoped when reading %s. Coping.",
|
||||
filename);
|
||||
tor_strstrip(string, "\r");
|
||||
}
|
||||
#endif
|
||||
close(fd);
|
||||
|
||||
Reference in New Issue
Block a user