Merge remote-tracking branch 'origin/master' into YaSp
[scilab.git] / scilab / modules / fileio / src / c / removedir.c
index d63fa72..1810315 100644 (file)
@@ -2,6 +2,7 @@
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2007 - INRIA - Allan CORNET
 * Copyright (C) 2010 - DIGITEO - Allan CORNET
+* Copyright (C) 2010 - DIGITEO - Antoine ELIAS
 *
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
@@ -30,6 +31,7 @@
 #include "isdir.h"
 #include "MALLOC.h"
 #include "charEncoding.h"
+#include "os_swprintf.h"
 /*--------------------------------------------------------------------------*/
 #ifdef _MSC_VER
 static int DeleteDirectory(wchar_t *refcstrRootDirectory);
@@ -88,7 +90,7 @@ BOOL removedirW(wchar_t *pathW)
 #ifdef _MSC_VER
 static int DeleteDirectory(wchar_t *refcstrRootDirectory)
 {
-#define DEFAULT_PATTERN L"%s/*.*"
+#define DEFAULT_PATTERN L"%ls/*.*"
     BOOL bDeleteSubdirectories = TRUE;
     BOOL bSubdirectory = FALSE;
     HANDLE hFile;
@@ -108,7 +110,7 @@ static int DeleteDirectory(wchar_t *refcstrRootDirectory)
     strPattern = (wchar_t*)MALLOC(sizeof(wchar_t) * len);
     if (strPattern)
     {
-        swprintf(strPattern, len, DEFAULT_PATTERN, refcstrRootDirectory);
+        os_swprintf(strPattern, len, DEFAULT_PATTERN, refcstrRootDirectory);
     }
     else
     {
@@ -128,12 +130,12 @@ static int DeleteDirectory(wchar_t *refcstrRootDirectory)
         {
             if ( (wcscmp(FileInformation.cFileName, L".") != 0) && (wcscmp(FileInformation.cFileName, L"..") != 0) )
             {
-#define FORMAT_PATH_TO_REMOVE L"%s\\%s"
+#define FORMAT_PATH_TO_REMOVE L"%ls\\%ls"
                 int len = (int) (wcslen(refcstrRootDirectory) + wcslen(FORMAT_PATH_TO_REMOVE) + wcslen((wchar_t*)(FileInformation.cFileName)) + 1);
                 strFilePath = (wchar_t*) MALLOC(sizeof(wchar_t) * len);
                 if (strFilePath)
                 {
-                    swprintf(strFilePath, len, FORMAT_PATH_TO_REMOVE, refcstrRootDirectory, FileInformation.cFileName);
+                    os_swprintf(strFilePath, len, FORMAT_PATH_TO_REMOVE, refcstrRootDirectory, FileInformation.cFileName);
                 }
 
                 if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)