avoid freeze when creating a directory in current path under Windows 80/16280/2
Antoine ELIAS [Mon, 30 Mar 2015 09:50:46 +0000 (11:50 +0200)]
test_run fileio createdir

Change-Id: I9826297597ba9312062ab2a6efe329cce045c4d8

scilab/modules/fileio/src/c/createdirectory.c

index 7cdfbcd..79c9157 100644 (file)
 #include <dirent.h>
 #else
 #include <Windows.h>
+#include <stdio.h>
 #endif
 #include "charEncoding.h"
 #include "MALLOC.h"
 #include "createdirectory.h"
 #include "isdir.h"
 #include "splitpath.h"
+#include "scicurdir.h"
 /*--------------------------------------------------------------------------*/
 #define DIRMODE 0777
 /*--------------------------------------------------------------------------*/
@@ -79,6 +81,21 @@ BOOL createdirectoryW(const wchar_t *pathW)
             wcscpy(path_out, drv);
             wcscat(path_out, dir);
 
+            //if there is no path_out, get current dir as reference.
+            if (wcslen(path_out) == 0)
+            {
+                int err = 0;
+                wchar_t * cur = NULL;
+                if (wcslen(pathW)  == 0)
+                {
+                    return FALSE;
+                }
+
+                cur = scigetcwdW(&err);
+                wcscpy(path_out, cur);
+                FREE(cur);
+            }
+
             if (CreateDirectoryExW(path_out, pathW, NULL))
             {
                 bOK = TRUE;