efl: add binary mode to f(re)open() calls
This allows better compatibility with Windows Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
d2a7882b73
commit
3b44645363
|
@ -196,7 +196,7 @@ evas_stringshare_add(const char *str)
|
|||
// {
|
||||
// char bf[256];
|
||||
// snprintf(bf, sizeof(bf), "strlog-%i", getpid());
|
||||
// f = fopen(bf, "w");
|
||||
// f = fopen(bf, "wb");
|
||||
// }
|
||||
hash_num = _evas_stringshare_hash_gen(str, &slen);
|
||||
for (el = share.buckets[hash_num]; el; pel = el, el = el->next)
|
||||
|
|
|
@ -387,11 +387,11 @@ _standardizes_header(const char *filename)
|
|||
static Eina_Bool
|
||||
_open_file_descriptors(const char *source, const char *header)
|
||||
{
|
||||
header_fd = fopen(header, "w");
|
||||
header_fd = fopen(header, "wb");
|
||||
if (!header_fd)
|
||||
return EINA_FALSE;
|
||||
|
||||
source_fd = fopen(source, "w");
|
||||
source_fd = fopen(source, "wb");
|
||||
if (!source_fd)
|
||||
goto err;
|
||||
|
||||
|
|
|
@ -7492,7 +7492,7 @@ using_file(const char *filename, const char type)
|
|||
FILE *f = NULL;
|
||||
|
||||
if (!options.watchfile) return;
|
||||
f = fopen(options.watchfile, "a");
|
||||
f = fopen(options.watchfile, "ab");
|
||||
if (!f) return;
|
||||
if (annotate)
|
||||
{
|
||||
|
|
|
@ -345,7 +345,7 @@ struct cpp_options {
|
|||
|
||||
char print_deps_missing_files;
|
||||
|
||||
/* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */
|
||||
/* If true, fopen (deps_file, "ab") else fopen (deps_file, "wb"). */
|
||||
char print_deps_append;
|
||||
|
||||
/* Nonzero means print names of header files (-H). */
|
||||
|
|
|
@ -74,7 +74,7 @@ main(int argc, char **argv)
|
|||
|
||||
if (!opts->out_fname || !strcmp(opts->out_fname, ""))
|
||||
opts->out_fname = "stdout";
|
||||
else if (!freopen(opts->out_fname, "w", stdout))
|
||||
else if (!freopen(opts->out_fname, "wb", stdout))
|
||||
cpp_pfatal_with_name(&parse_in, opts->out_fname);
|
||||
|
||||
for (i = 0;; i++)
|
||||
|
|
|
@ -129,7 +129,7 @@ _do(Client *c, char *op, unsigned char *d, int size)
|
|||
c2->evlog_fetch_timer = ecore_timer_add(0.2, _cb_evlog, c2);
|
||||
snprintf(buf, sizeof(buf), "%s/efl_debug_evlog-%ld.log",
|
||||
getenv("HOME"), (long)c2->pid);
|
||||
c2->evlog_file = fopen(buf, "w");
|
||||
c2->evlog_file = fopen(buf, "wb");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ _address_book_load(Eina_Model *model)
|
|||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(filename, EINA_FALSE);
|
||||
|
||||
f = fopen(filename, "r");
|
||||
f = fopen(filename, "rb");
|
||||
|
||||
// Now that we have used filename, we must free its memory holder:
|
||||
eina_value_flush(&val);
|
||||
|
|
|
@ -271,7 +271,7 @@ ecore_init(void)
|
|||
char tmp[1024];
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "ecore_mem_stat.%i", getpid());
|
||||
_ecore_memory_statistic_file = fopen(tmp, "w");
|
||||
_ecore_memory_statistic_file = fopen(tmp, "wb");
|
||||
#endif
|
||||
_ecore_memory_pid = getpid();
|
||||
ecore_animator_add(_ecore_memory_statistic, NULL);
|
||||
|
|
|
@ -1589,7 +1589,7 @@ _ecore_con_ssl_server_privkey_add_openssl(Ecore_Con_Server *obj,
|
|||
FILE *fp = NULL;
|
||||
EVP_PKEY *privkey = NULL;
|
||||
|
||||
if (!(fp = fopen(key_file, "r")))
|
||||
if (!(fp = fopen(key_file, "rb")))
|
||||
goto error;
|
||||
|
||||
SSL_ERROR_CHECK_GOTO_ERROR(!(privkey = PEM_read_PrivateKey(fp, NULL, NULL, NULL)));
|
||||
|
@ -1616,7 +1616,7 @@ _ecore_con_ssl_server_cert_add_openssl(Ecore_Con_Server *obj,
|
|||
FILE *fp = NULL;
|
||||
X509 *cert = NULL;
|
||||
|
||||
if (!(fp = fopen(cert_file, "r")))
|
||||
if (!(fp = fopen(cert_file, "rb")))
|
||||
goto error;
|
||||
|
||||
SSL_ERROR_CHECK_GOTO_ERROR(!(cert = PEM_read_X509(fp, NULL, NULL, NULL)));
|
||||
|
|
|
@ -443,7 +443,7 @@ _drm_init(int *flags)
|
|||
if (stat("/sys/module/vboxvideo", &st) == 0)
|
||||
{
|
||||
/*
|
||||
FILE *fp = fopen("/sys/module/vboxvideo/version", "r");
|
||||
FILE *fp = fopen("/sys/module/vboxvideo/version", "rb");
|
||||
if (fp)
|
||||
{
|
||||
if (fgets(buf, sizeof(buf), fp))
|
||||
|
@ -462,7 +462,7 @@ _drm_init(int *flags)
|
|||
// only do this on new kernels = let's say 3.14 and up. 3.16 definitely
|
||||
// works
|
||||
{
|
||||
FILE *fp = fopen("/proc/sys/kernel/osrelease", "r");
|
||||
FILE *fp = fopen("/proc/sys/kernel/osrelease", "rb");
|
||||
if (fp)
|
||||
{
|
||||
if (fgets(buf, sizeof(buf), fp))
|
||||
|
|
|
@ -3224,7 +3224,7 @@ typedef void (*Eet_Dump_Callback)(void *data, const char *str);
|
|||
* int len;
|
||||
* void *data;
|
||||
*
|
||||
* f = fopen(file, "r");
|
||||
* f = fopen(file, "rb");
|
||||
* fseek(f, 0, SEEK_END);
|
||||
* len = ftell(f);
|
||||
* rewind(f);
|
||||
|
@ -4030,7 +4030,7 @@ eet_data_xattr_cipher_set(const char *filename,
|
|||
* int len;
|
||||
* void *data;
|
||||
*
|
||||
* f = fopen(file, "r");
|
||||
* f = fopen(file, "rb");
|
||||
* fseek(f, 0, SEEK_END);
|
||||
* len = ftell(f);
|
||||
* rewind(f);
|
||||
|
|
|
@ -192,7 +192,7 @@ on_error:
|
|||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
/* Load the X509 certificate in memory. */
|
||||
fp = fopen(certificate_file, "r");
|
||||
fp = fopen(certificate_file, "rb");
|
||||
if (!fp)
|
||||
return NULL;
|
||||
|
||||
|
@ -207,7 +207,7 @@ on_error:
|
|||
goto on_error;
|
||||
|
||||
/* Load the private key in memory. */
|
||||
fp = fopen(private_key_file, "r");
|
||||
fp = fopen(private_key_file, "rb");
|
||||
if (!fp)
|
||||
goto on_error;
|
||||
|
||||
|
|
|
@ -687,7 +687,7 @@ efreet_menu_save(Efreet_Menu *menu, const char *path)
|
|||
EINA_SAFETY_ON_NULL_RETURN_VAL(menu, 0);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0);
|
||||
|
||||
f = fopen(path, "w");
|
||||
f = fopen(path, "wb");
|
||||
if (!f) return 0;
|
||||
fprintf(f, "<?xml version=\"1.0\"?>\n");
|
||||
fprintf(f, "<!DOCTYPE Menu PUBLIC \"-//freedesktop//DTD Menu 1.0//EN\" "
|
||||
|
|
|
@ -752,7 +752,7 @@ efreet_mime_fallback_check(const char *file)
|
|||
if (ecore_file_can_exec(file))
|
||||
return _mime_application_x_executable;
|
||||
|
||||
if (!(f = fopen(file, "r"))) return NULL;
|
||||
if (!(f = fopen(file, "rb"))) return NULL;
|
||||
|
||||
i = fread(buf, 1, sizeof(buf), f);
|
||||
fclose(f);
|
||||
|
|
|
@ -215,7 +215,7 @@ efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete)
|
|||
/* create info file */
|
||||
snprintf(dest, sizeof(dest), "%s/info/%s.trashinfo", trash_dir, fname);
|
||||
|
||||
if ((f = fopen(dest, "w")))
|
||||
if ((f = fopen(dest, "wb")))
|
||||
{
|
||||
fputs("[Trash Info]\n", f);
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ eina_benchmark_run(Eina_Benchmark *bench)
|
|||
bench->name,
|
||||
bench->run);
|
||||
|
||||
main_script = fopen(buffer, "w");
|
||||
main_script = fopen(buffer, "wb");
|
||||
if (!main_script)
|
||||
return NULL;
|
||||
|
||||
|
@ -293,7 +293,7 @@ eina_benchmark_run(Eina_Benchmark *bench)
|
|||
bench->run,
|
||||
run->name);
|
||||
|
||||
current_data = fopen(buffer, "w");
|
||||
current_data = fopen(buffer, "wb");
|
||||
if (!current_data)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -617,7 +617,7 @@ elua_util_script_run(Elua_State *es, int argc, char **argv, int n, int *quit)
|
|||
if (fname)
|
||||
{
|
||||
/* check if there is a file of that name */
|
||||
FILE *f = fopen(fname, "r");
|
||||
FILE *f = fopen(fname, "rb");
|
||||
if (f)
|
||||
{
|
||||
fclose(f);
|
||||
|
|
|
@ -10,7 +10,7 @@ get_cmdline_from_argv(const char *fname, const char **argv)
|
|||
char pbuf[PATH_MAX];
|
||||
const char *arg = NULL;
|
||||
|
||||
FILE *testf = fopen(fname, "r");
|
||||
FILE *testf = fopen(fname, "rb");
|
||||
if (!testf)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ rend_dbg(const char *txt)
|
|||
#ifdef STDOUT_DBG
|
||||
dbf = stdout;
|
||||
#else
|
||||
dbf = fopen("EVAS-RENDER-DEBUG.log", "w");
|
||||
dbf = fopen("EVAS-RENDER-DEBUG.log", "wb");
|
||||
#endif
|
||||
if (!dbf) return;
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ fb_list_modes(unsigned int *num_return)
|
|||
int num;
|
||||
|
||||
num = 0;
|
||||
f = fopen("/etc/fb.modes","r");
|
||||
f = fopen("/etc/fb.modes","rb");
|
||||
if (!f)
|
||||
{
|
||||
*num_return = 0;
|
||||
|
|
|
@ -111,7 +111,7 @@ _save_direct_tgv(RGBA_Image *im, const char *file, int compress)
|
|||
// header[7]: options (unused)
|
||||
header[7] = 0;
|
||||
|
||||
f = fopen(file, "w");
|
||||
f = fopen(file, "wb");
|
||||
if (!f) return 0;
|
||||
|
||||
// Write header
|
||||
|
@ -300,7 +300,7 @@ evas_image_save_file_tgv(RGBA_Image *im,
|
|||
// Note: consider extending the header instead of filling all the bits here
|
||||
header[7] = 0;
|
||||
|
||||
f = fopen(file, "w");
|
||||
f = fopen(file, "wb");
|
||||
if (!f) return 0;
|
||||
|
||||
// Write header
|
||||
|
|
|
@ -163,7 +163,7 @@ _save_mesh(Evas_Canvas3D_Mesh_Data *pd,
|
|||
|
||||
evas_model_save_data_from_mesh(pd, f, header, &data);
|
||||
|
||||
FILE * _obj_file = fopen(_obj_file_name, "w+");
|
||||
FILE * _obj_file = fopen(_obj_file_name, "wb+");
|
||||
if (!_obj_file)
|
||||
{
|
||||
ERR("File open '%s' for save failed", _obj_file_name);
|
||||
|
@ -191,7 +191,7 @@ _save_material(Evas_Canvas3D_Mesh_Data *pd EINA_UNUSED,
|
|||
const char *_mtl_file_name,
|
||||
Evas_Canvas3D_Material_Data *mat)
|
||||
{
|
||||
FILE * _mtl_file = fopen(_mtl_file_name, "w+");
|
||||
FILE * _mtl_file = fopen(_mtl_file_name, "wb+");
|
||||
if (!_mtl_file)
|
||||
{
|
||||
ERR("File open '%s' for save failed", _mtl_file_name);
|
||||
|
|
|
@ -75,7 +75,7 @@ evas_model_save_file_ply(const Evas_Canvas3D_Mesh *mesh,
|
|||
if (!evas_model_save_header_from_mesh(pd, f, &header)) return;
|
||||
evas_model_save_data_from_mesh(pd, f, header, &data);
|
||||
|
||||
FILE *_ply_file = fopen(file, "w+");
|
||||
FILE *_ply_file = fopen(file, "wb+");
|
||||
if (!_ply_file)
|
||||
{
|
||||
ERR("File open '%s' for save failed", file);
|
||||
|
|
|
@ -3516,7 +3516,7 @@ int dns_hosts_loadpath(struct dns_hosts *hosts, const char *path) {
|
|||
FILE *fp;
|
||||
int error;
|
||||
|
||||
if (!(fp = fopen(path, "r")))
|
||||
if (!(fp = fopen(path, "rb")))
|
||||
return dns_syerr();
|
||||
|
||||
error = dns_hosts_loadfile(hosts, fp);
|
||||
|
@ -4073,7 +4073,7 @@ int dns_resconf_loadpath(struct dns_resolv_conf *resconf, const char *path) {
|
|||
FILE *fp;
|
||||
int error;
|
||||
|
||||
if (!(fp = fopen(path, "r")))
|
||||
if (!(fp = fopen(path, "rb")))
|
||||
return dns_syerr();
|
||||
|
||||
error = dns_resconf_loadfile(resconf, fp);
|
||||
|
@ -4456,7 +4456,7 @@ int dns_nssconf_loadpath(struct dns_resolv_conf *resconf, const char *path) {
|
|||
FILE *fp;
|
||||
int error;
|
||||
|
||||
if (!(fp = fopen(path, "r")))
|
||||
if (!(fp = fopen(path, "rb")))
|
||||
return dns_syerr();
|
||||
|
||||
error = dns_nssconf_loadfile(resconf, fp);
|
||||
|
|
|
@ -108,7 +108,7 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
char* filename = argv[2];
|
||||
FILE* file = fopen(filename, "r");
|
||||
FILE* file = fopen(filename, "rb");
|
||||
if (file == NULL) {
|
||||
perror("fopen");
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
void
|
||||
_writeToFile(const char *filePath, char *text)
|
||||
{
|
||||
FILE *f = fopen(filePath, "r+");
|
||||
FILE *f = fopen(filePath, "rb+");
|
||||
if (f == NULL)
|
||||
f = fopen(filePath, "w");
|
||||
f = fopen(filePath, "wb");
|
||||
fail_if(f == NULL);
|
||||
fprintf(f, "%s\n", text);
|
||||
fclose(f);
|
||||
|
|
|
@ -1734,7 +1734,7 @@ START_TEST(eet_identity_simple)
|
|||
|
||||
fail_if(-1 == (fd = mkstemp(file)));
|
||||
fail_if(!!close(fd));
|
||||
fail_if(!(noread = fopen("/dev/null", "w")));
|
||||
fail_if(!(noread = fopen("/dev/null", "wb")));
|
||||
|
||||
/* Sign an eet file. */
|
||||
ef = eet_open(file, EET_FILE_MODE_WRITE);
|
||||
|
|
|
@ -72,7 +72,7 @@ static Eina_Bool _create_directory(void *data)
|
|||
|
||||
static Eina_Bool _create_file(void *data)
|
||||
{
|
||||
FILE *fd = fopen((const char*)data, "w+");
|
||||
FILE *fd = fopen((const char*)data, "wb+");
|
||||
ck_assert_ptr_ne(fd, NULL);
|
||||
fprintf(fd, "test test");
|
||||
fclose(fd);
|
||||
|
@ -88,7 +88,7 @@ static Eina_Bool _delete_file(void *data)
|
|||
|
||||
static Eina_Bool _modify_file(void *data)
|
||||
{
|
||||
FILE *fd = fopen((const char*)data, "a");
|
||||
FILE *fd = fopen((const char*)data, "ab");
|
||||
ck_assert_ptr_ne(fd, NULL);
|
||||
fprintf(fd, "appened");
|
||||
fclose(fd);
|
||||
|
|
|
@ -116,7 +116,7 @@ START_TEST(elua_api)
|
|||
fail_if(!elua_util_script_run(st, 2, cargv, 1, &quit));
|
||||
fail_if(quit != 1);
|
||||
|
||||
f = fopen(buf, "w");
|
||||
f = fopen(buf, "wb");
|
||||
fail_if(!f);
|
||||
fprintf(f, "return false");
|
||||
fclose(f);
|
||||
|
|
|
@ -66,7 +66,7 @@ main(int argc, char **argv)
|
|||
|
||||
for (l = 1; l < argc; l++)
|
||||
{
|
||||
if (!(fptr = fopen(argv[l], "r")))
|
||||
if (!(fptr = fopen(argv[l], "rb")))
|
||||
{
|
||||
fprintf(stderr, "Could not open %s\n", argv[l]);
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue