+2008-02-18 Alexander Larsson <alexl@redhat.com>
+
+ * glocalfile.c:
+ * glocalfileoutputstream.c:
+ Open files with O_BINARY on windows. (#517140)
+
2008-02-14 Alexander Larsson <alexl@redhat.com>
* glocalfileoutputstream.c:
#include <sys/mount.h>
#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#if defined(HAVE_STATFS) && defined(HAVE_STATVFS)
/* Some systems have both statfs and statvfs, pick the
most "native" for these */
int fd;
struct stat buf;
- fd = g_open (local->filename, O_RDONLY, 0);
+ fd = g_open (local->filename, O_RDONLY|O_BINARY, 0);
if (fd == -1)
{
int errsv = errno;
#endif
#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#include "gioalias.h"
#define g_local_file_output_stream_get_type _g_local_file_output_stream_get_type
else
mode = 0666;
- fd = g_open (filename, O_CREAT | O_EXCL | O_WRONLY, mode);
+ fd = g_open (filename, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, mode);
if (fd == -1)
{
int errsv = errno;
else
mode = 0666;
- fd = g_open (filename, O_CREAT | O_APPEND | O_WRONLY, mode);
+ fd = g_open (filename, O_CREAT | O_APPEND | O_WRONLY | O_BINARY, mode);
if (fd == -1)
{
int errsv = errno;
/* We only need read access to the original file if we are creating a backup.
* We also add O_CREATE to avoid a race if the file was just removed */
if (create_backup)
- open_flags = O_RDWR | O_CREAT;
+ open_flags = O_RDWR | O_CREAT | O_BINARY;
else
- open_flags = O_WRONLY | O_CREAT;
+ open_flags = O_WRONLY | O_CREAT | O_BINARY;
/* Some systems have O_NOFOLLOW, which lets us avoid some races
* when finding out if the file we opened was a symlink */
}
bfd = g_open (backup_filename,
- O_WRONLY | O_CREAT | O_EXCL,
+ O_WRONLY | O_CREAT | O_EXCL | O_BINARY,
original_stat.st_mode & 0777);
if (bfd == -1)
mode = 0666;
/* If the file doesn't exist, create it */
- fd = g_open (filename, O_CREAT | O_EXCL | O_WRONLY, mode);
+ fd = g_open (filename, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, mode);
if (fd == -1 && errno == EEXIST)
{