open files in binary mode, to fix problems on Windows. Fix a constness

SVN revision: 34931
This commit is contained in:
doursse 2008-06-28 09:11:48 +00:00 committed by doursse
parent d7a634d3da
commit 074765d3aa
5 changed files with 15 additions and 6 deletions

View File

@ -3,6 +3,15 @@
#include "edje_main.h"
/*
* On Windows, if the file is not opened in binary mode,
* read does not return the correct size, because of
* CR / LF translation.
*/
#ifndef O_BINARY
# define O_BINARY 0
#endif
/* types */
typedef struct _New_Object_Handler New_Object_Handler;
typedef struct _New_Statement_Handler New_Statement_Handler;

View File

@ -749,7 +749,7 @@ st_data_file(void)
di->key = parse_str(0);
filename = parse_str(1);
fd = open(filename, O_RDONLY);
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0)
{
fprintf(stderr, "%s: Error. %s:%i when opening file \"%s\": \"%s\"\n",

View File

@ -610,7 +610,7 @@ data_write(void)
char tmpo[4096];
int ret;
f = fopen(tmpn, "w");
f = fopen(tmpn, "wb");
if (f)
{
Evas_List *ll;

View File

@ -611,7 +611,7 @@ compile(void)
int fd;
off_t size;
char *data, *p;
char *tmpdir;
const char *tmpdir;
#ifdef HAVE_EVIL
tmpdir = evil_tmpdir_get();
@ -693,7 +693,7 @@ compile(void)
free(def);
*/
}
fd = open(file_in, O_RDONLY);
fd = open(file_in, O_RDONLY | O_BINARY);
if (fd < 0)
{
fprintf(stderr, "%s: Error. cannot open file \"%s\" for input. %s\n",

View File

@ -226,7 +226,7 @@ output(void)
printf("ERROR: potential security violation. attempt to write in parent dir.\n");
exit (-1);
}
f = fopen(out, "w");
f = fopen(out, "wb");
if (!f)
{
printf("ERROR: unable to write file (%s).\n", out);
@ -292,7 +292,7 @@ output(void)
printf("ERROR: potential security violation. attempt to write in parent dir.\n");
exit (-1);
}
f = fopen(out, "w");
f = fopen(out, "wb");
fprintf(f, "#!/bin/sh\n");
fprintf(f, "%s $@ -id . -fd . %s -o %s.edj\n", edje_file->compiler, sf->name, outdir);
fclose(f);