* src/lib/evil_stdio.c:

replace / by \ in the path passed to fopen



SVN revision: 39036
This commit is contained in:
Vincent Torri 2009-02-16 08:42:41 +00:00
parent 860fc287c2
commit a66c46264c
2 changed files with 32 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2009-02-16 Vincent Torri <doursse at users dot sf dot net>
* src/lib/evil_stdio.c:
replace / by \ in the path passed to fopen
2009-02-01 Vincent Torri <doursse at users dot sf dot net>
* doc/Makefile.am:

View File

@ -30,11 +30,12 @@ FILE *evil_fopen(const char *path, const char *mode)
{
FILE *f;
char *filename;
char *tmp;
if (!path || !*path)
return NULL;
if (*path != '\\')
if ((*path != '\\') && (*path != '/'))
{
char buf[PATH_MAX];
int l1;
@ -54,11 +55,20 @@ FILE *evil_fopen(const char *path, const char *mode)
filename[l1 + 1 + l2] = '\0';
}
else
filename = (char *)path;
filename = _strdup(path);
tmp = filename;
while (*tmp)
{
if (*tmp == '/')
*tmp = '\\';
tmp++;
}
printf ("fopen : %s\n", filename);
f = fopen(filename, mode);
if (*path != '\\')
free(filename);
free(filename);
return f;
}
@ -78,6 +88,7 @@ FILE *evil_fopen_native(const char *path, const char *mode)
{
HANDLE handle;
char *filename;
char *tmp;
wchar_t *wfilename;
DWORD access = GENERIC_READ;
DWORD creation;
@ -85,7 +96,7 @@ FILE *evil_fopen_native(const char *path, const char *mode)
if (!path || !*path || !mode || !*mode)
return NULL;
if (*path != '\\')
if ((*path != '\\') && (*path != '/'))
{
char buf[PATH_MAX];
int l1;
@ -105,11 +116,19 @@ FILE *evil_fopen_native(const char *path, const char *mode)
filename[l1 + 1 + l2] = '\0';
}
else
filename = (char *)path;
filename = _strdup(path);
tmp = filename;
while (*tmp)
{
if (*tmp == '/')
*tmp = '\\';
tmp++;
}
printf ("fopen native : %s\n", filename);
wfilename = evil_char_to_wchar(filename);
if (*path != '\\')
free(filename);
free(filename);
if (!wfilename)
return NULL;