efl: add binary mode to open() calls

This allows better compatibility with Windows

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Vincent Torri 2015-12-03 11:42:08 +01:00 committed by Cedric BAIL
parent 4f242fb48a
commit 0497b9685c
12 changed files with 71 additions and 23 deletions

View File

@ -20,6 +20,10 @@
#define ERR(...) EINA_LOG_DOM_ERR(es_log_dom, __VA_ARGS__)
#define CRI(...) EINA_LOG_DOM_CRIT(es_log_dom, __VA_ARGS__)
#ifndef O_BINARY
# define O_BINARY 0
#endif
static int es_log_dom = -1;
static Ecore_Con_Server *svr = NULL;
static Eet_Data_Descriptor *es_edd = NULL;
@ -186,7 +190,7 @@ cdrom_timer(Eeze_Scanner_Device *dev)
/* cdrom already mounted, no need to poll */
if (dev->mounted) return EINA_TRUE;
devpath = eeze_udev_syspath_get_devpath(dev->device);
fd = open(devpath, O_RDONLY);
fd = open(devpath, O_RDONLY | O_BINARY);
if (fd < 0)
{
Eina_List *l;

View File

@ -22,6 +22,10 @@ static int _efreet_icon_cache_log_dom = -1;
#include "efreet_private.h"
#include "efreet_cache_private.h"
#ifndef O_BINARY
# define O_BINARY 0
#endif
static Eina_Array *exts = NULL;
static Eina_Array *extra_dirs = NULL;
static Eina_Array *strs = NULL;
@ -676,7 +680,7 @@ cache_lock_file(void)
int lockfd;
snprintf(file, sizeof(file), "%s/efreet/icon_data.lock", efreet_cache_home_get());
lockfd = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
lockfd = open(file, O_CREAT | O_BINARY | O_RDWR, S_IRUSR | S_IWUSR);
if (lockfd < 0) return -1;
efreet_fsetowner(lockfd);

View File

@ -10,6 +10,10 @@
#include <Ecore.h>
#include <Ecore_Con.h>
#ifndef O_BINARY
# define O_BINARY 0
#endif
struct _request
{
long size;
@ -68,7 +72,7 @@ main(int argc, const char *argv[])
return -1;
}
fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
fd = open(filename, O_CREAT | O_BINARY | O_WRONLY | O_TRUNC, 0644);
if (fd == -1)
{

View File

@ -35,6 +35,10 @@
#include <malloc.h>
#endif
#ifndef O_BINARY
# define O_BINARY 0
#endif
static Ecore_Version _version = { VMAJ, VMIN, VMIC, VREV };
EAPI Ecore_Version *ecore_version = &_version;
@ -777,11 +781,11 @@ _ecore_fps_debug_init(void)
tmp = eina_environment_tmp_get();
pid = (int)getpid();
snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid);
_ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
_ecore_fps_debug_fd = open(buf, O_CREAT | O_BINARY | O_TRUNC | O_RDWR, 0644);
if (_ecore_fps_debug_fd < 0)
{
unlink(buf);
_ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
_ecore_fps_debug_fd = open(buf, O_CREAT | O_BINARY | O_TRUNC | O_RDWR, 0644);
}
if (_ecore_fps_debug_fd >= 0)
{

View File

@ -34,6 +34,10 @@
#include "ecore_evas_extn.h"
#include "ecore_evas_win32.h"
#ifndef O_BINARY
# define O_BINARY 0
#endif
EAPI Eina_Bool _ecore_evas_app_comp_sync = EINA_FALSE;
EAPI int _ecore_evas_log_dom = -1;
static int _ecore_evas_init_count = 0;
@ -2973,11 +2977,11 @@ _ecore_evas_fps_debug_init(void)
snprintf(buf, sizeof(buf), "%s/.ecore_evas_fps_debug-%i",
eina_environment_tmp_get(), (int)getpid());
_ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
_ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_BINARY | O_TRUNC | O_RDWR, 0644);
if (_ecore_evas_fps_debug_fd < 0)
{
unlink(buf);
_ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644);
_ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_BINARY | O_TRUNC | O_RDWR, 0644);
}
if (_ecore_evas_fps_debug_fd >= 0)
{

View File

@ -14,6 +14,10 @@
#include <Ecore.h>
#include <Ecore_Buffer.h>
#ifndef O_BINARY
# define O_BINARY 0
#endif
typedef struct _Ecore_Buffer_Shm_Data Ecore_Buffer_Shm_Data;
struct _Ecore_Buffer_Shm_Data {
@ -102,7 +106,7 @@ _ecore_buffer_shm_buffer_export(Ecore_Buffer_Module_Data bmdata EINA_UNUSED, Eco
Ecore_Buffer_Shm_Data* b = bdata;
int fd;
fd = open(b->file, O_RDWR | O_CLOEXEC);
fd = open(b->file, O_RDWR | O_BINARY | O_CLOEXEC);
if (id) *id = fd;
return EXPORT_TYPE_FD;

View File

@ -1,5 +1,9 @@
#include "ecore_evas_extn_engine.h"
#ifndef O_BINARY
# define O_BINARY 0
#endif
struct _Extnbuf
{
const char *file, *lock;
@ -165,7 +169,7 @@ _extnbuf_lock_file_set(Extnbuf *b, const char *file)
}
b->lock = eina_stringshare_add(file);
if (!b->lock) goto err;
b->lockfd = open(b->lock, O_RDWR);
b->lockfd = open(b->lock, O_RDWR | O_BINARY);
if (b->lockfd >= 0) return EINA_TRUE;
err:
if (b->lock) eina_stringshare_del(b->lock);

View File

@ -16,6 +16,10 @@
#include <fcntl.h>
#include <ctype.h>
#ifndef O_BINARY
# define O_BINARY 0
#endif
typedef struct _Evas_Loader_Internal Evas_Loader_Internal;
struct _Evas_Loader_Internal
{
@ -329,7 +333,7 @@ getdata:
// open
if (tmpfname)
fd = open(tmpfname, O_RDONLY, S_IRUSR);
fd = open(tmpfname, O_RDONLY | O_BINARY, S_IRUSR);
#ifdef HAVE_SHM_OPEN
else if (shmfname)
fd = shm_open(shmfname, O_RDONLY, S_IRUSR);

View File

@ -15,6 +15,10 @@
#include "ecore_suite.h"
#ifndef O_BINARY
# define O_BINARY 0
#endif
#define MAXSIZE 256
void
@ -242,7 +246,7 @@ START_TEST(ecore_test_ecore_file_operations)
src_file = get_tmp_file();
fail_if(!src_file);
fail_if(ecore_file_remove(src_file) != EINA_TRUE);
fd = open(src_file, O_RDWR|O_CREAT, 0700);
fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0700);
fail_if(fd < 0);
fail_if(close(fd) != 0);
fail_if(ecore_file_can_exec(src_file) != EINA_TRUE);
@ -295,7 +299,7 @@ START_TEST(ecore_test_ecore_file_operations)
src_file = get_tmp_file();
fail_if(!src_file);
fail_if(ecore_file_remove(src_file) != EINA_TRUE);
fd = open(src_file, O_RDWR|O_CREAT, 0400);
fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0400);
fail_if(fd < 0);
fail_if(close(fd) != 0);
fail_if(ecore_file_can_read(src_file) != EINA_TRUE);
@ -306,7 +310,7 @@ START_TEST(ecore_test_ecore_file_operations)
src_file = get_tmp_file();
fail_if(!src_file);
fail_if(ecore_file_remove(src_file) != EINA_TRUE);
fd = open(src_file, O_RDWR|O_CREAT, 0200);
fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0200);
fail_if(fd < 0);
fail_if(close(fd) != 0);
fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
@ -316,7 +320,7 @@ START_TEST(ecore_test_ecore_file_operations)
src_file = get_tmp_file();
fail_if(!src_file);
fail_if(ecore_file_remove(src_file) != EINA_TRUE);
fd = open(src_file, O_RDWR|O_CREAT, 0100);
fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0100);
fail_if(fd < 0);
fail_if(close(fd) != 0);
fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
@ -355,7 +359,7 @@ START_TEST(ecore_test_ecore_file_path)
src_file = get_tmp_file();
fail_if(!src_file);
fail_if(ecore_file_remove(src_file) != EINA_TRUE);
fd = open(src_file, O_RDWR|O_CREAT, 0700);
fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0700);
fail_if(fd < 0);
fail_if(close(fd) != 0);
fail_if(ecore_file_can_exec(src_file) != EINA_TRUE);

View File

@ -17,6 +17,10 @@
#include "eet_suite.h"
#ifndef O_BINARY
# define O_BINARY 0
#endif
static char _key_pem[PATH_MAX] = "";
static char _cert_pem[PATH_MAX] = "";
static char _key_enc[PATH_MAX] = "";
@ -1775,7 +1779,7 @@ START_TEST(eet_identity_simple)
eet_clearcache();
/* Corrupting the file. */
fd = open(file, O_WRONLY);
fd = open(file, O_WRONLY | O_BINARY);
fail_if(fd < 0);
fail_if(lseek(fd, 200, SEEK_SET) != 200);

View File

@ -38,6 +38,10 @@
# define PATH_SEP_C '/'
#endif
#ifndef O_BINARY
# define O_BINARY 0
#endif
static int default_dir_rights = 0777;
const int file_min_offset = 1;
@ -353,12 +357,12 @@ START_TEST(eina_file_map_new_test)
strcpy(test_file2_path, (char *)test_dirname);
strcat(test_file2_path, test_file2_name_part);
fd = open(test_file_path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
fd = open(test_file_path, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
fail_if(fd == 0);
fail_if(write(fd, eina_map_test_string, strlen(eina_map_test_string)) != (ssize_t) strlen(eina_map_test_string));
close(fd);
fd = open(test_file2_path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
fd = open(test_file2_path, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
fail_if(fd == 0);
fail_if(write(fd, big_buffer, big_buffer_size - file_min_offset) != big_buffer_size - file_min_offset);
close(fd);
@ -566,7 +570,7 @@ START_TEST(eina_test_file_xattr)
eina_init();
test_file_path = get_full_path(XATTR_TEST_DIR, filename);
fd = open(test_file_path, O_RDONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
fd = open(test_file_path, O_RDONLY | O_BINARY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
fail_if(fd == 0);
close(fd);
@ -699,12 +703,12 @@ START_TEST(eina_test_file_statat)
test_file1_path = get_full_path(test_dirname, "example1.txt");
test_file2_path = get_full_path(test_dirname, "example2.txt");
fd = open(test_file1_path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
fd = open(test_file1_path, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
fail_if(fd == 0);
fail_if(write(fd, template, template_size) != template_size);
close(fd);
fd = open(test_file2_path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
fd = open(test_file2_path, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
fail_if(fd == 0);
fail_if(write(fd, template, template_size) != template_size);
close(fd);

View File

@ -14,6 +14,10 @@
#include "eio_suite.h"
#ifndef O_BINARY
# define O_BINARY 0
#endif
static unsigned int default_rights = 0755;
static int test_count = 0;
static const char *good_dirs[] =
@ -154,7 +158,7 @@ create_test_dirs(Eina_Tmpstr *test_dirname)
for (i = 0; i != count; ++i)
{
Eina_Tmpstr *filename = get_full_path(test_dirname, files[i]);
fd = open(filename, O_RDWR|O_CREAT, default_rights);
fd = open(filename, O_RDWR | O_BINARY | O_CREAT, default_rights);
fail_if(fd < 0);
fail_if(close(fd) != 0);
eina_tmpstr_del(filename);
@ -163,7 +167,7 @@ create_test_dirs(Eina_Tmpstr *test_dirname)
for (i = 0; i != count; ++i)
{
Eina_Tmpstr *filename = get_full_path(nested_dirname, files[i]);
fd = open(filename, O_RDWR|O_CREAT, default_rights);
fd = open(filename, O_RDWR | O_BINARY | O_CREAT, default_rights);
fail_if(fd < 0);
fail_if(close(fd) != 0);
eina_tmpstr_del(filename);