forked from enlightenment/efl
* evil.pc.in:
remove -ldl * src/lib/evil_dirent.c: change guards * src/lib/evil_stdio.c: * src/lib/evil_stdio.h: add some checks, add a function that more or less mimic fopen, but with native win32 api calls. This is only for the evas loader and saver of png files and works only for Windows CE. * src/lib/evil_unistd.c: move a free() and remove debug calls. SVN revision: 37570
This commit is contained in:
parent
a00a2a3636
commit
ad106db9fe
|
@ -1,3 +1,21 @@
|
|||
2008-11-09 Vincent Torri <doursse at users dot sf dot net>
|
||||
|
||||
* evil.pc.in:
|
||||
remove -ldl
|
||||
|
||||
* src/lib/evil_dirent.c:
|
||||
change guards
|
||||
|
||||
* src/lib/evil_stdio.c:
|
||||
* src/lib/evil_stdio.h:
|
||||
add some checks,
|
||||
add a function that more or less mimic fopen, but with
|
||||
native win32 api calls. This is only for the evas loader
|
||||
and saver of png files and works only for Windows CE.
|
||||
|
||||
* src/lib/evil_unistd.c:
|
||||
move a free() and remove debug calls.
|
||||
|
||||
2008-11-05 Vincent Torri <doursse at users dot sf dot net>
|
||||
|
||||
* src/lib/evil_stdio.c:
|
||||
|
|
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
|||
Name: evil
|
||||
Description: Library that ports on Windows some specific Unix functions.
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -levil -ldl
|
||||
Libs: -L${libdir} -levil
|
||||
Libs.private:
|
||||
Cflags: -I${includedir}
|
||||
|
|
|
@ -20,8 +20,7 @@ struct DIR
|
|||
};
|
||||
|
||||
|
||||
#if defined (_MSC_VER) || \
|
||||
(defined (_WIN32_WCE) && ! defined (__CEGCC__))
|
||||
#ifndef __CEGCC__
|
||||
|
||||
DIR *opendir(char const *name)
|
||||
{
|
||||
|
@ -195,4 +194,4 @@ struct dirent *readdir(DIR *dir)
|
|||
return &dir->dirent;
|
||||
}
|
||||
|
||||
#endif /* _MSC_VER || ( _WIN32_WCE && ! __CEGCC__ ) */
|
||||
#endif /* ! __CEGCC__ */
|
||||
|
|
|
@ -29,6 +29,9 @@ FILE *evil_fopen(const char *path, const char *mode)
|
|||
FILE *f;
|
||||
char *filename;
|
||||
|
||||
if (!path || !*path)
|
||||
return NULL;
|
||||
|
||||
if (*path != '\\')
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
@ -41,6 +44,8 @@ FILE *evil_fopen(const char *path, const char *mode)
|
|||
l1 = strlen(buf);
|
||||
l2 = strlen(path);
|
||||
filename = (char *)malloc(l1 + 1 + l2 + 1);
|
||||
if (!filename)
|
||||
return NULL;
|
||||
memcpy(filename, buf, l1);
|
||||
filename[l1] = '\\';
|
||||
memcpy(filename + l1 + 1, path, l2);
|
||||
|
@ -63,3 +68,107 @@ void evil_rewind(FILE *stream)
|
|||
|
||||
|
||||
#endif /* _WIN32_WCE && ! __CEGCC__ */
|
||||
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
|
||||
FILE *evil_fopen_native(const char *path, const char *mode)
|
||||
{
|
||||
HANDLE handle;
|
||||
char *filename;
|
||||
wchar_t *wfilename;
|
||||
DWORD access = GENERIC_READ;
|
||||
DWORD creation;
|
||||
|
||||
if (!path || !*path || !mode || !*mode)
|
||||
return NULL;
|
||||
|
||||
if (*path != '\\')
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
int l1;
|
||||
int l2;
|
||||
|
||||
if (!evil_getcwd(buf, PATH_MAX))
|
||||
return NULL;
|
||||
|
||||
l1 = strlen(buf);
|
||||
l2 = strlen(path);
|
||||
filename = (char *)malloc(l1 + 1 + l2 + 1);
|
||||
if (!filename)
|
||||
return NULL;
|
||||
memcpy(filename, buf, l1);
|
||||
filename[l1] = '\\';
|
||||
memcpy(filename + l1 + 1, path, l2);
|
||||
filename[l1 + 1 + l2] = '\0';
|
||||
}
|
||||
else
|
||||
filename = (char *)path;
|
||||
|
||||
wfilename = evil_char_to_wchar(filename);
|
||||
if (*path != '\\')
|
||||
free(filename);
|
||||
|
||||
if (!wfilename)
|
||||
return NULL;
|
||||
|
||||
if (*mode == 'r')
|
||||
{
|
||||
access = GENERIC_READ;
|
||||
creation = OPEN_EXISTING;
|
||||
}
|
||||
if (*mode == 'w')
|
||||
{
|
||||
access = GENERIC_WRITE;
|
||||
creation = CREATE_ALWAYS;
|
||||
}
|
||||
|
||||
handle = CreateFile(wfilename,
|
||||
access,
|
||||
0, NULL,
|
||||
creation,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
free(wfilename);
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
_evil_last_error_display(__FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (FILE *)handle;
|
||||
}
|
||||
|
||||
size_t evil_fread_native(void* buffer, size_t size, size_t count, FILE* stream)
|
||||
{
|
||||
HANDLE handle;
|
||||
DWORD bytes_read;
|
||||
BOOL res;
|
||||
|
||||
if ((size == 0) || (count == 0))
|
||||
return 0;
|
||||
|
||||
handle = (HANDLE)stream;
|
||||
res = ReadFile(handle, buffer, size * count, &bytes_read, NULL);
|
||||
if (!res)
|
||||
{
|
||||
_evil_last_error_display(__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (bytes_read != size * count) ? 0 : 1;
|
||||
}
|
||||
|
||||
int evil_fclose_native(FILE *stream)
|
||||
{
|
||||
if (!CloseHandle((HANDLE)stream))
|
||||
{
|
||||
_evil_last_error_display(__FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* _WIN32_WCE */
|
||||
|
|
|
@ -30,4 +30,15 @@ EAPI void evil_rewind(FILE *stream);
|
|||
#endif /* _WIN32_WCE && ! __CEGCC__ */
|
||||
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
|
||||
EAPI FILE *evil_fopen_native(const char *path, const char *mode);
|
||||
|
||||
EAPI size_t evil_fread_native(void* buffer, size_t size, size_t count, FILE* stream);
|
||||
|
||||
EAPI int evil_fclose_native(FILE *stream);
|
||||
|
||||
#endif /* _WIN32_WCE */
|
||||
|
||||
|
||||
#endif /* __EVIL_STDIO_H__ */
|
||||
|
|
|
@ -163,9 +163,9 @@ evil_stat(const char *file_name, struct stat *st)
|
|||
memcpy(tmp + l1 + 1, file_name, l2);
|
||||
tmp[l1 + 1 + l2] = '\0';
|
||||
file = evil_char_to_wchar(tmp);
|
||||
free(tmp);
|
||||
if (!file)
|
||||
return -1;
|
||||
free(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -176,11 +176,6 @@ evil_stat(const char *file_name, struct stat *st)
|
|||
|
||||
free(f);
|
||||
|
||||
{
|
||||
char *tmp = evil_wchar_to_char(file);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
handle = FindFirstFile(file, &data);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue