do not use CreateDirectoryW with instl compiler in 32 bits 88/14388/1
Antoine ELIAS [Thu, 10 Apr 2014 13:35:12 +0000 (15:35 +0200)]
Change-Id: I4169f0b1f6dc7c8d596de22afcc706f817bf567a

scilab/modules/core/src/c/tmpdir.c
scilab/modules/fileio/src/c/copyfile_windows.c
scilab/modules/fileio/src/c/createdirectory.c
scilab/modules/spreadsheet/src/c/ripole/ole.c

index 61b8676..a08acd9 100644 (file)
@@ -65,7 +65,7 @@ void createScilabTMPDIR(void)
         static wchar_t bufenv[PATH_MAX + 16];
         char *TmpDir = NULL;
         swprintf(wctmp_dir, PATH_MAX + FILENAME_MAX + 1, L"%sSCI_TMP_%d_", wcTmpDirDefault, (int) _getpid());
-        if ( CreateDirectoryW(wctmp_dir, NULL) == FALSE)
+        if ( createdirectoryW(wctmp_dir) == FALSE)
         {
             DWORD attribs = GetFileAttributesW (wctmp_dir);
             if (attribs & FILE_ATTRIBUTE_DIRECTORY)
index 75b3ef1..e41a817 100644 (file)
@@ -95,7 +95,7 @@ static int CopyDirectoryFunction_windows(wchar_t *DestinationDirectory, wchar_t
     else
     {
         /* Create the destdir */
-        ans = CreateDirectoryW(DestinationDirectory, NULL);
+        ans = createdirectoryW(DestinationDirectory);
     }
     FindClose(find_handle);
 
index 0e3932e..7cdfbcd 100644 (file)
@@ -24,6 +24,7 @@
 #include "MALLOC.h"
 #include "createdirectory.h"
 #include "isdir.h"
+#include "splitpath.h"
 /*--------------------------------------------------------------------------*/
 #define DIRMODE 0777
 /*--------------------------------------------------------------------------*/
@@ -70,7 +71,15 @@ BOOL createdirectoryW(const wchar_t *pathW)
                 path = NULL;
             }
 #else
-            if (CreateDirectoryW(pathW, NULL))
+            wchar_t path_out[MAX_PATH];
+            wchar_t drv[MAX_PATH];
+            wchar_t dir[MAX_PATH];
+            splitpathW(pathW, TRUE, drv, dir, NULL, NULL);
+
+            wcscpy(path_out, drv);
+            wcscat(path_out, dir);
+
+            if (CreateDirectoryExW(path_out, pathW, NULL))
             {
                 bOK = TRUE;
             }
index b04d3a6..03e8534 100644 (file)
@@ -15,6 +15,7 @@
 #include "ole.h"
 #include "localization.h"
 #include "charEncoding.h"
+#include "createdirectory.h"
 /** Sector ID values (predefined) **/
 #define OLE_SECTORID_FREE      -1 /** Unallocated sector **/
 #define OLE_SECTORID_ENDOFCHAIN        -2 /** Sector marks the end of the a sector-ID chain **/
@@ -1583,7 +1584,7 @@ int OLE_open_directory(struct OLE_object *ole, char *directory)
     {
         wchar_t *wdirectory = to_wide_string(directory);
 
-        result = CreateDirectoryW(wdirectory, NULL);
+        result = createdirectoryW(wdirectory);
         FREE(wdirectory);
     }
     /* If the function succeeds, the return value is nonzero.