mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 07:38:54 +02:00
Open files with O_BINARY on windows. (#517140)
2008-02-18 Alexander Larsson <alexl@redhat.com> * glocalfile.c: * glocalfileoutputstream.c: Open files with O_BINARY on windows. (#517140) svn path=/trunk/; revision=6531
This commit is contained in:
committed by
Alexander Larsson
parent
ee9020e45e
commit
b221d1b36d
@@ -1,3 +1,9 @@
|
|||||||
|
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>
|
2008-02-14 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
* glocalfileoutputstream.c:
|
* glocalfileoutputstream.c:
|
||||||
|
@@ -46,6 +46,10 @@
|
|||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_BINARY
|
||||||
|
#define O_BINARY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_STATFS) && defined(HAVE_STATVFS)
|
#if defined(HAVE_STATFS) && defined(HAVE_STATVFS)
|
||||||
/* Some systems have both statfs and statvfs, pick the
|
/* Some systems have both statfs and statvfs, pick the
|
||||||
most "native" for these */
|
most "native" for these */
|
||||||
@@ -1110,7 +1114,7 @@ g_local_file_read (GFile *file,
|
|||||||
int fd;
|
int fd;
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
fd = g_open (local->filename, O_RDONLY, 0);
|
fd = g_open (local->filename, O_RDONLY|O_BINARY, 0);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
|
@@ -48,6 +48,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_BINARY
|
||||||
|
#define O_BINARY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "gioalias.h"
|
#include "gioalias.h"
|
||||||
|
|
||||||
#define g_local_file_output_stream_get_type _g_local_file_output_stream_get_type
|
#define g_local_file_output_stream_get_type _g_local_file_output_stream_get_type
|
||||||
@@ -456,7 +460,7 @@ _g_local_file_output_stream_create (const char *filename,
|
|||||||
else
|
else
|
||||||
mode = 0666;
|
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)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
@@ -497,7 +501,7 @@ _g_local_file_output_stream_append (const char *filename,
|
|||||||
else
|
else
|
||||||
mode = 0666;
|
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)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
@@ -611,9 +615,9 @@ handle_overwrite_open (const char *filename,
|
|||||||
/* We only need read access to the original file if we are creating a backup.
|
/* 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 */
|
* We also add O_CREATE to avoid a race if the file was just removed */
|
||||||
if (create_backup)
|
if (create_backup)
|
||||||
open_flags = O_RDWR | O_CREAT;
|
open_flags = O_RDWR | O_CREAT | O_BINARY;
|
||||||
else
|
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
|
/* Some systems have O_NOFOLLOW, which lets us avoid some races
|
||||||
* when finding out if the file we opened was a symlink */
|
* when finding out if the file we opened was a symlink */
|
||||||
@@ -766,7 +770,7 @@ handle_overwrite_open (const char *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bfd = g_open (backup_filename,
|
bfd = g_open (backup_filename,
|
||||||
O_WRONLY | O_CREAT | O_EXCL,
|
O_WRONLY | O_CREAT | O_EXCL | O_BINARY,
|
||||||
original_stat.st_mode & 0777);
|
original_stat.st_mode & 0777);
|
||||||
|
|
||||||
if (bfd == -1)
|
if (bfd == -1)
|
||||||
@@ -890,7 +894,7 @@ _g_local_file_output_stream_replace (const char *filename,
|
|||||||
mode = 0666;
|
mode = 0666;
|
||||||
|
|
||||||
/* If the file doesn't exist, create it */
|
/* 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)
|
if (fd == -1 && errno == EEXIST)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user