From 9c4b61e61f6896612139971591777dca3974b95d Mon Sep 17 00:00:00 2001 From: caro Date: Fri, 26 Nov 2010 13:47:51 +0000 Subject: [PATCH] on Windows, "C:" is not a directory, but a drive. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@55013 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_file/ecore_file.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/ecore_file/ecore_file.c b/src/lib/ecore_file/ecore_file.c index b568ca2..acd24e2 100644 --- a/src/lib/ecore_file/ecore_file.c +++ b/src/lib/ecore_file/ecore_file.c @@ -431,6 +431,15 @@ _ecore_file_mkpath_if_not_exists(const char *path) { struct stat st; + /* Windows: path like C: or D: etc are valid, but stat() returns an error */ +#ifdef _WIN32 + if ((strlen(path) == 2) && + ((path[0] >= 'a' && path[0] <= 'z') || + (path[0] >= 'A' && path[0] <= 'Z')) && + (path[1] == ':')) + return EINA_TRUE; +#endif + if (stat(path, &st) < 0) return ecore_file_mkdir(path); else if (!S_ISDIR(st.st_mode)) @@ -446,9 +455,9 @@ _ecore_file_mkpath_if_not_exists(const char *path) * @return EINA_TRUE on success, EINA_FALSE otherwise. * * This function create @p path and all the subdirectories it - * contains. The separator is '/' so, on Windows, '\' must be replaced - * by '/'. If @p path exists, this function returns EINA_TRUE - * immediatly. It returns EINA_TRUE on success, EINA_FALSE otherwise. + * contains. The separator is '/' or '\'. If @p path exists, this + * function returns EINA_TRUE immediatly. It returns EINA_TRUE on + * success, EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_mkpath(const char *path) @@ -462,7 +471,7 @@ ecore_file_mkpath(const char *path) for (i = 0; path[i] != '\0'; ss[i] = path[i], i++) { if (i == sizeof(ss) - 1) return EINA_FALSE; - if ((path[i] == '/') && (i > 0)) + if (((path[i] == '/') || (path[i] == '\\')) && (i > 0)) { ss[i] = '\0'; if (!_ecore_file_mkpath_if_not_exists(ss)) -- 2.7.4