forked from enlightenment/efl
efl: add macro to swap Windows and Unix path separators.
This commit is contained in:
parent
b631878821
commit
9e745d4a2c
|
@ -102,10 +102,10 @@ _ecore_evas_engine_init(void)
|
|||
for (j = 0; j < ((sizeof (paths) / sizeof (char*)) - 1); ++j)
|
||||
for (i = j + 1; i < sizeof (paths) / sizeof (char*); ++i)
|
||||
if (paths[i] && paths[j] && !strcmp(paths[i], paths[j]))
|
||||
{
|
||||
free(paths[i]);
|
||||
paths[i] = NULL;
|
||||
}
|
||||
{
|
||||
free(paths[i]);
|
||||
paths[i] = NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof (paths) / sizeof (char*); ++i)
|
||||
if (paths[i])
|
||||
|
@ -154,20 +154,23 @@ _ecore_evas_available_engines_get(void)
|
|||
|
||||
EINA_LIST_FOREACH(_engines_paths, l, path)
|
||||
{
|
||||
it = eina_file_direct_ls(path);
|
||||
it = eina_file_direct_ls(path);
|
||||
|
||||
if (it)
|
||||
{
|
||||
EINA_ITERATOR_FOREACH(it, info)
|
||||
{
|
||||
char tmp[PATH_MAX];
|
||||
snprintf(tmp, sizeof (tmp), "%s/%s/" ECORE_EVAS_ENGINE_NAME,
|
||||
info->path, MODULE_ARCH);
|
||||
if (it)
|
||||
{
|
||||
EINA_ITERATOR_FOREACH(it, info)
|
||||
{
|
||||
char tmp[PATH_MAX];
|
||||
snprintf(tmp, sizeof (tmp), "%s/%s/" ECORE_EVAS_ENGINE_NAME,
|
||||
info->path, MODULE_ARCH);
|
||||
|
||||
if (_file_exists(tmp))
|
||||
if (_file_exists(tmp))
|
||||
{
|
||||
const char *name;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
EVIL_PATH_SEP_WIN32_TO_UNIX(info->path);
|
||||
#endif
|
||||
name = strrchr(info->path, '/');
|
||||
if (name) name++;
|
||||
else name = info->path;
|
||||
|
@ -246,9 +249,9 @@ _ecore_evas_available_engines_get(void)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
eina_iterator_free(it);
|
||||
}
|
||||
}
|
||||
eina_iterator_free(it);
|
||||
}
|
||||
}
|
||||
|
||||
_engines_available = result;
|
||||
|
|
|
@ -497,7 +497,6 @@ char *
|
|||
eina_file_cleanup(Eina_Tmpstr *path)
|
||||
{
|
||||
char *result;
|
||||
char *p;
|
||||
|
||||
result = strdup(path ? path : "");
|
||||
eina_tmpstr_del(path);
|
||||
|
@ -505,12 +504,7 @@ eina_file_cleanup(Eina_Tmpstr *path)
|
|||
if (!result)
|
||||
return NULL;
|
||||
|
||||
p = result;
|
||||
while (*p)
|
||||
{
|
||||
if (*p == '\\') *p = '/';
|
||||
p++;
|
||||
}
|
||||
EVIL_PATH_SEP_WIN32_TO_UNIX(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -196,7 +196,6 @@ dladdr (const void *addr EVIL_UNUSED, Dl_info *info)
|
|||
TCHAR tpath[PATH_MAX];
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
char *path;
|
||||
char *tmp;
|
||||
size_t length;
|
||||
int ret = 0;
|
||||
|
||||
|
@ -236,13 +235,7 @@ dladdr (const void *addr EVIL_UNUSED, Dl_info *info)
|
|||
path[PATH_MAX - 1] = '\0';
|
||||
}
|
||||
|
||||
/* replace '/' by '\' */
|
||||
tmp = path;
|
||||
while (*tmp)
|
||||
{
|
||||
if (*tmp == '/') *tmp = '\\';
|
||||
tmp++;
|
||||
}
|
||||
EVIL_PATH_SEP_UNIX_TO_WIN32(path);
|
||||
|
||||
memcpy (info->dli_fname, path, length + 1);
|
||||
info->dli_fbase = NULL;
|
||||
|
|
|
@ -19,8 +19,7 @@ struct DIR
|
|||
DIR *opendir(char const *name)
|
||||
{
|
||||
DIR *dir;
|
||||
char *tmp1;
|
||||
char *tmp2;
|
||||
char *tmp;
|
||||
DWORD attr;
|
||||
size_t l;
|
||||
#ifdef UNICODE
|
||||
|
@ -71,39 +70,34 @@ DIR *opendir(char const *name)
|
|||
}
|
||||
|
||||
l = strlen(name);
|
||||
tmp1 = (char *)malloc(sizeof(char) * l + 5);
|
||||
if (!tmp1)
|
||||
tmp = (char *)malloc(sizeof(char) * l + 5);
|
||||
if (!tmp)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(tmp1, name, l);
|
||||
memcpy(tmp1 + l, "\\*.*", 5);
|
||||
memcpy(tmp, name, l);
|
||||
memcpy(tmp + l, "\\*.*", 5);
|
||||
|
||||
tmp2 = tmp1;
|
||||
while (*tmp2)
|
||||
{
|
||||
if (*tmp2 == '/') *tmp2 = '\\';
|
||||
tmp2++;
|
||||
}
|
||||
EVIL_PATH_SEP_UNIX_TO_WIN32(tmp);
|
||||
|
||||
#ifdef UNICODE
|
||||
wname = evil_char_to_wchar(tmp1);
|
||||
wname = evil_char_to_wchar(tmp);
|
||||
if (!wname)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
free(tmp1);
|
||||
free(tmp);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
dir->handle = FindFirstFile(wname, &dir->data);
|
||||
free(wname);
|
||||
#else
|
||||
dir->handle = FindFirstFile(tmp1, &dir->data);
|
||||
dir->handle = FindFirstFile(tmp, &dir->data);
|
||||
#endif
|
||||
|
||||
free(tmp1);
|
||||
free(tmp);
|
||||
|
||||
if (dir->handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
|
|
@ -31,12 +31,8 @@ evil_basename(char *path)
|
|||
memcpy(_evil_basename_buf, "C:\\", 4);
|
||||
return _evil_basename_buf;
|
||||
}
|
||||
p2 = p1;
|
||||
while (*p2)
|
||||
{
|
||||
if (*p2 == '/') *p2 = '\\';
|
||||
p2++;
|
||||
}
|
||||
|
||||
EVIL_PATH_SEP_UNIX_TO_WIN32(p1);
|
||||
|
||||
/* remove trailing backslashes */
|
||||
p2 = p1 + (length - 1);
|
||||
|
|
|
@ -29,7 +29,6 @@ FILE *evil_fopen(const char *path, const char *mode)
|
|||
{
|
||||
FILE *f;
|
||||
char *filename;
|
||||
char *tmp;
|
||||
|
||||
if (!path || !*path)
|
||||
return NULL;
|
||||
|
@ -56,13 +55,7 @@ FILE *evil_fopen(const char *path, const char *mode)
|
|||
else
|
||||
filename = _strdup(path);
|
||||
|
||||
tmp = filename;
|
||||
while (*tmp)
|
||||
{
|
||||
if (*tmp == '/')
|
||||
*tmp = '\\';
|
||||
tmp++;
|
||||
}
|
||||
EVIL_PATH_SEP_UNIX_TO_WIN32(filename);
|
||||
|
||||
printf ("fopen : %s\n", filename);
|
||||
|
||||
|
@ -108,7 +101,6 @@ FILE *evil_fopen_native(const char *path, const char *mode)
|
|||
{
|
||||
HANDLE handle;
|
||||
char *filename;
|
||||
char *tmp;
|
||||
wchar_t *wfilename;
|
||||
DWORD acs = GENERIC_READ;
|
||||
DWORD creation;
|
||||
|
@ -138,13 +130,7 @@ FILE *evil_fopen_native(const char *path, const char *mode)
|
|||
else
|
||||
filename = _strdup(path);
|
||||
|
||||
tmp = filename;
|
||||
while (*tmp)
|
||||
{
|
||||
if (*tmp == '/')
|
||||
*tmp = '\\';
|
||||
tmp++;
|
||||
}
|
||||
EVIL_PATH_SEP_UNIX_TO_WIN32(filename);
|
||||
printf ("fopen native : %s\n", filename);
|
||||
|
||||
wfilename = evil_char_to_wchar(filename);
|
||||
|
|
|
@ -13,6 +13,20 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
#define EVIL_PATH_SEP_SWAP(p, s1, s2) \
|
||||
do { \
|
||||
char *_evil_path_tmp; \
|
||||
_evil_path_tmp = p; \
|
||||
while (*_evil_path_tmp) \
|
||||
{ \
|
||||
if (*_evil_path_tmp == s1) \
|
||||
*_evil_path_tmp = s2; \
|
||||
_evil_path_tmp++; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define EVIL_PATH_SEP_WIN32_TO_UNIX(p) EVIL_PATH_SEP_SWAP(p, '\\', '/')
|
||||
#define EVIL_PATH_SEP_UNIX_TO_WIN32(p) EVIL_PATH_SEP_SWAP(p, '/', '\\')
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
|
||||
|
|
|
@ -169,7 +169,6 @@ evil_stat(const char *file_name, struct stat *st)
|
|||
WIN32_FIND_DATA data;
|
||||
HANDLE handle;
|
||||
char *f;
|
||||
char *tmp;
|
||||
wchar_t *file;
|
||||
int permission = 0;
|
||||
|
||||
|
@ -180,12 +179,7 @@ evil_stat(const char *file_name, struct stat *st)
|
|||
if (!f)
|
||||
return -1;
|
||||
|
||||
tmp = f;
|
||||
while (*tmp)
|
||||
{
|
||||
if (*tmp == '/') *tmp = '\\';
|
||||
tmp++;
|
||||
}
|
||||
EVIL_PATH_SEP_UNIX_TO_WIN32(f);
|
||||
|
||||
if (!strcmp(file_name, "\\"))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue