add getshortpathname function 41/2441/3
Antoine ELIAS [Wed, 10 Nov 2010 11:08:02 +0000 (12:08 +0100)]
Change-Id: I9d389f68104b8c4ab6d5733c512aafdec35551d2

12 files changed:
scilab/modules/fileio/Makefile.am
scilab/modules/fileio/Makefile.in
scilab/modules/fileio/fileio.vcproj
scilab/modules/fileio/includes/fileio_gw.hxx
scilab/modules/fileio/includes/getshortpathname.h
scilab/modules/fileio/includes/gw_fileio.h
scilab/modules/fileio/sci_gateway/c/gw_fileio.c
scilab/modules/fileio/sci_gateway/c/sci_getshortpathname.c [deleted file]
scilab/modules/fileio/sci_gateway/cpp/fileio_gw.cpp
scilab/modules/fileio/sci_gateway/cpp/fileio_gw.vcproj
scilab/modules/fileio/sci_gateway/cpp/sci_getshortpathname.cpp [new file with mode: 0644]
scilab/modules/fileio/src/c/getshortpathname.c

index cc183a0..695cbde 100644 (file)
@@ -63,7 +63,6 @@ sci_gateway/c/sci_maxfiles.c \
 sci_gateway/c/sci_getdrives.c \
 sci_gateway/c/sci_fullpath.c \
 sci_gateway/c/sci_pathsep.c \
-sci_gateway/c/sci_getshortpathname.c \
 sci_gateway/c/sci_getlongpathname.c \
 sci_gateway/c/sci_fileext.c \
 sci_gateway/c/sci_removedir.c \
@@ -99,7 +98,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_basename.cpp \
        sci_gateway/cpp/sci_fileinfo.cpp \
        sci_gateway/cpp/sci_isfile.cpp \
-       sci_gateway/cpp/sci_deletefile.cpp
+       sci_gateway/cpp/sci_deletefile.cpp \
+       sci_gateway/cpp/sci_getshortpathname.cpp
 
 
 FILEIO_CPP_SOURCES = \
index c79a8e0..d2b29b1 100644 (file)
@@ -159,7 +159,6 @@ am__objects_3 = libscifileio_la-gw_fileio.lo \
        libscifileio_la-sci_maxfiles.lo \
        libscifileio_la-sci_getdrives.lo \
        libscifileio_la-sci_fullpath.lo libscifileio_la-sci_pathsep.lo \
-       libscifileio_la-sci_getshortpathname.lo \
        libscifileio_la-sci_getlongpathname.lo \
        libscifileio_la-sci_fileext.lo \
        libscifileio_la-sci_removedir.lo \
@@ -183,7 +182,8 @@ am__objects_4 = libscifileio_la-fileio_gw.lo \
        libscifileio_la-sci_findfiles.lo \
        libscifileio_la-sci_basename.lo \
        libscifileio_la-sci_fileinfo.lo libscifileio_la-sci_isfile.lo \
-       libscifileio_la-sci_deletefile.lo
+       libscifileio_la-sci_deletefile.lo \
+       libscifileio_la-sci_getshortpathname.lo
 am_libscifileio_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
        $(am__objects_3) $(am__objects_4)
 libscifileio_la_OBJECTS = $(am_libscifileio_la_OBJECTS)
@@ -528,7 +528,6 @@ sci_gateway/c/sci_maxfiles.c \
 sci_gateway/c/sci_getdrives.c \
 sci_gateway/c/sci_fullpath.c \
 sci_gateway/c/sci_pathsep.c \
-sci_gateway/c/sci_getshortpathname.c \
 sci_gateway/c/sci_getlongpathname.c \
 sci_gateway/c/sci_fileext.c \
 sci_gateway/c/sci_removedir.c \
@@ -564,7 +563,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_basename.cpp \
        sci_gateway/cpp/sci_fileinfo.cpp \
        sci_gateway/cpp/sci_isfile.cpp \
-       sci_gateway/cpp/sci_deletefile.cpp
+       sci_gateway/cpp/sci_deletefile.cpp \
+       sci_gateway/cpp/sci_getshortpathname.cpp
 
 FILEIO_CPP_SOURCES = \
        src/cpp/expandPathVariable.cpp \
@@ -1290,13 +1290,6 @@ libscifileio_la-sci_pathsep.lo: sci_gateway/c/sci_pathsep.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -c -o libscifileio_la-sci_pathsep.lo `test -f 'sci_gateway/c/sci_pathsep.c' || echo '$(srcdir)/'`sci_gateway/c/sci_pathsep.c
 
-libscifileio_la-sci_getshortpathname.lo: sci_gateway/c/sci_getshortpathname.c
-@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -MT libscifileio_la-sci_getshortpathname.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_getshortpathname.Tpo -c -o libscifileio_la-sci_getshortpathname.lo `test -f 'sci_gateway/c/sci_getshortpathname.c' || echo '$(srcdir)/'`sci_gateway/c/sci_getshortpathname.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_getshortpathname.Tpo $(DEPDIR)/libscifileio_la-sci_getshortpathname.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_getshortpathname.c' object='libscifileio_la-sci_getshortpathname.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -c -o libscifileio_la-sci_getshortpathname.lo `test -f 'sci_gateway/c/sci_getshortpathname.c' || echo '$(srcdir)/'`sci_gateway/c/sci_getshortpathname.c
-
 libscifileio_la-sci_getlongpathname.lo: sci_gateway/c/sci_getlongpathname.c
 @am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -MT libscifileio_la-sci_getlongpathname.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_getlongpathname.Tpo -c -o libscifileio_la-sci_getlongpathname.lo `test -f 'sci_gateway/c/sci_getlongpathname.c' || echo '$(srcdir)/'`sci_gateway/c/sci_getlongpathname.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_getlongpathname.Tpo $(DEPDIR)/libscifileio_la-sci_getlongpathname.Plo
@@ -1612,6 +1605,13 @@ libscifileio_la-sci_deletefile.lo: sci_gateway/cpp/sci_deletefile.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_la-sci_deletefile.lo `test -f 'sci_gateway/cpp/sci_deletefile.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_deletefile.cpp
 
+libscifileio_la-sci_getshortpathname.lo: sci_gateway/cpp/sci_getshortpathname.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_la-sci_getshortpathname.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_getshortpathname.Tpo -c -o libscifileio_la-sci_getshortpathname.lo `test -f 'sci_gateway/cpp/sci_getshortpathname.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_getshortpathname.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-sci_getshortpathname.Tpo $(DEPDIR)/libscifileio_la-sci_getshortpathname.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_getshortpathname.cpp' object='libscifileio_la-sci_getshortpathname.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_la-sci_getshortpathname.lo `test -f 'sci_gateway/cpp/sci_getshortpathname.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_getshortpathname.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index ab46377..5f143d3 100644 (file)
                                >
                        </File>
                        <File
-                               RelativePath=".\sci_gateway\c\sci_getshortpathname.c"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\sci_gateway\c\sci_maxfiles.c"
                                >
                        </File>
index 19ac617..e0d662c 100644 (file)
@@ -51,5 +51,6 @@ CPP_GATEWAY_PROTOTYPE(sci_basename);
 CPP_GATEWAY_PROTOTYPE(sci_isfile);
 CPP_GATEWAY_PROTOTYPE(sci_fileinfo);
 CPP_GATEWAY_PROTOTYPE(sci_deletefile);
+CPP_GATEWAY_PROTOTYPE(sci_getshortpathname);
 
 #endif /* !__FILEIO_GW_HXX__ */
index 59e5edc..55bad4d 100644 (file)
@@ -16,6 +16,7 @@
 #include "dynlib_fileio.h"
 #include "machine.h" /* C2F */
 #include "BOOL.h" /* BOOL */
+#include <wchar.h> /* wchar_t */
 
 /**
 * Retrieves the short path form of the specified path
@@ -29,5 +30,7 @@ FILEIO_IMPEXP char *getshortpathname(char *longpathname, BOOL *convertok);
 
 FILEIO_IMPEXP int C2F(getshortpathname)(char *pathname,int *len);
 
+FILEIO_IMPEXP wchar_t* getshortpathnameW(wchar_t* _pwstLongPathName, BOOL* _pbOK);
+
 #endif /* __GETSHORTPATHNAME_H__ */
 /*--------------------------------------------------------------------------*/
index 5cea466..4d0e58f 100644 (file)
@@ -33,7 +33,6 @@ FILEIO_IMPEXP int sci_getdrives(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_fullpath(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_pathsep(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_getlongpathname(char *fname,unsigned long fname_len);
-FILEIO_IMPEXP int sci_getshortpathname(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_fileext(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_createdir(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_removedir(char *fname,unsigned long fname_len);
index 9ec40c7..60cea0b 100644 (file)
@@ -44,7 +44,7 @@ static gw_generic_table Tab[]={
        {sci_pathsep,"pathsep"},
        {NULL, ""}, //filesep
        {sci_getlongpathname,"getlongpathname"},
-       {sci_getshortpathname,"getshortpathname"},
+       {NULL ,""}, //getshortpathname
        {sci_fileext,"fileext"},
        {NULL, ""}, //isdir
        {sci_removedir,"removedir"},
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_getshortpathname.c b/scilab/modules/fileio/sci_gateway/c/sci_getshortpathname.c
deleted file mode 100644 (file)
index b693854..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA - Allan CORNET
- * Copyright (C) 2009 - DIGITEO - Allan CORNET
- * 
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at    
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-/*--------------------------------------------------------------------------*/
-#include <string.h>
-#include "gw_fileio.h"
-#include "stack-c.h"
-#include "getshortpathname.h"
-#include "MALLOC.h"
-#include "Scierror.h"
-#include "localization.h"
-#include "freeArrayOfString.h"
-#include "BOOL.h"
-/*--------------------------------------------------------------------------*/
-int sci_getshortpathname(char *fname,unsigned long l)
-{
-       CheckRhs(0,1);
-       CheckLhs(1,2);
-
-       if (GetType(1) == sci_strings)
-       {
-               int n1 = 0,m1 = 0, m1n1 = 0;
-               char **LongNames = NULL;
-               char **ShortNames = NULL;
-               BOOL *bOK = NULL;
-               int i = 0;
-
-               GetRhsVar(1,MATRIX_OF_STRING_DATATYPE,&m1,&n1,&LongNames);
-               m1n1 = m1*n1;
-
-               if (m1n1 > 0)
-               {
-                       ShortNames = (char**) MALLOC(sizeof(char*)* (m1n1));
-                       bOK = (BOOL*) MALLOC(sizeof(BOOL)*(m1n1));
-
-                       if ( (ShortNames == NULL) || (bOK == NULL) )
-                       {
-                               freeArrayOfString(LongNames, m1n1);
-                               Scierror(999,"%s: Memory allocation error.\n", fname);
-                               return 0;
-                       }
-               }
-
-               for (i = 0;i < m1n1; i++)
-               {
-                       ShortNames[i] = getshortpathname(LongNames[i], &bOK[i]);
-               }
-               freeArrayOfString(LongNames, m1n1);
-
-               CreateVarFromPtr( Rhs+1,MATRIX_OF_STRING_DATATYPE,&m1,&n1,ShortNames);
-               LhsVar(1) = Rhs+1;
-
-               if (Lhs == 2) 
-               {
-                       CreateVarFromPtr(Rhs+2,MATRIX_OF_BOOLEAN_DATATYPE, &m1, &n1, &bOK);
-                       LhsVar(2) = Rhs + 2;
-               }
-
-               C2F(putlhsvar)();
-
-               freeArrayOfString(ShortNames, m1n1);
-               if (bOK) {FREE(bOK); bOK = NULL;}
-       }
-       else
-       {
-               Scierror(999,_("%s: Wrong type for input argument: A string expected.\n"),fname);
-       }
-       return 0;
-}
-/*--------------------------------------------------------------------------*/
index ab736d0..84d0e30 100644 (file)
@@ -40,5 +40,6 @@ bool FileioModule::Load()
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"isfile", &sci_isfile, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"fileinfo", &sci_fileinfo, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"deletefile", &sci_deletefile, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"getshortpathname", &sci_getshortpathname, MODULE_NAME));
     return true;
 }
index 6e08975..6ea0160 100644 (file)
                                >
                        </File>
                        <File
-                               RelativePath=".\sci_fileinfo.cpp"
+                               RelativePath=".\sci_deletefile.cpp"
                                >
                        </File>
                        <File
-                               RelativePath=".\sci_deletefile.cpp"
+                               RelativePath=".\sci_fileinfo.cpp"
                                >
                        </File>
                        <File
                                >
                        </File>
                        <File
+                               RelativePath=".\sci_getshortpathname.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\sci_isdir.cpp"
                                >
                        </File>
diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_getshortpathname.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_getshortpathname.cpp
new file mode 100644 (file)
index 0000000..890c178
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007 - INRIA - Allan CORNET
+ * Copyright (C) 2009 - 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
+ * you should have received as part of this distribution.  The terms
+ * are also available at    
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+/*--------------------------------------------------------------------------*/
+#include "fileio_gw.hxx"
+
+extern "C"
+{
+#include <string.h>
+#include "getshortpathname.h"
+#include "MALLOC.h"
+#include "Scierror.h"
+#include "localization.h"
+}
+/*--------------------------------------------------------------------------*/
+Function::ReturnValue sci_getshortpathname(typed_list &in, int _iRetCount, typed_list &out)
+{
+    if(in.size() != 1)
+    {
+        ScierrorW(999, _W("%ls: Wrong number of input arguments: %d expected.\n"), L"getshortpathname" , 1);
+        return Function::Error;
+    }
+
+    if(_iRetCount != 1 && _iRetCount != 2)
+    {
+         ScierrorW(78, _W("%ls: Wrong number of output argument(s): %d to %d expected.\n"), L"getshortpathname", 1, 2);
+        return Function::Error;
+    }
+
+    if(in[0]->isString() == false)
+    {
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: Matrix of strings expected.\n"), L"getshortpathname", 1);
+        return Function::Error;
+    }
+
+    String* pS  = in[0]->getAsString();
+    
+    String* pOut1 = new String(pS->rows_get() , pS->cols_get());
+    Bool* pOut2 = new Bool(pS->rows_get() , pS->cols_get());
+    int* pBool = pOut2->bool_get();
+    for(int i = 0 ; i < pS->size_get(); i++)
+    {
+        pOut1->string_set(i, getshortpathnameW(pS->string_get(i), &pBool[i]));
+    }
+
+    out.push_back(pOut1);
+    if(_iRetCount == 2)
+    {
+        out.push_back(pOut2);
+    }
+    else
+    {
+        delete pOut2;
+    }
+
+    return Function::OK;
+       //CheckRhs(0,1);
+       //CheckLhs(1,2);
+
+       //if (GetType(1) == sci_strings)
+       //{
+       //      int n1 = 0,m1 = 0, m1n1 = 0;
+       //      char **LongNames = NULL;
+       //      char **ShortNames = NULL;
+       //      BOOL *bOK = NULL;
+       //      int i = 0;
+
+       //      GetRhsVar(1,MATRIX_OF_STRING_DATATYPE,&m1,&n1,&LongNames);
+       //      m1n1 = m1*n1;
+
+       //      if (m1n1 > 0)
+       //      {
+       //              ShortNames = (char**) MALLOC(sizeof(char*)* (m1n1));
+       //              bOK = (BOOL*) MALLOC(sizeof(BOOL)*(m1n1));
+
+       //              if ( (ShortNames == NULL) || (bOK == NULL) )
+       //              {
+       //                      freeArrayOfString(LongNames, m1n1);
+       //                      Scierror(999,"%s: Memory allocation error.\n", fname);
+       //                      return 0;
+       //              }
+       //      }
+
+       //      for (i = 0;i < m1n1; i++)
+       //      {
+       //              ShortNames[i] = getshortpathname(LongNames[i], &bOK[i]);
+       //      }
+       //      freeArrayOfString(LongNames, m1n1);
+
+       //      CreateVarFromPtr( Rhs+1,MATRIX_OF_STRING_DATATYPE,&m1,&n1,ShortNames);
+       //      LhsVar(1) = Rhs+1;
+
+       //      if (Lhs == 2) 
+       //      {
+       //              CreateVarFromPtr(Rhs+2,MATRIX_OF_BOOLEAN_DATATYPE, &m1, &n1, &bOK);
+       //              LhsVar(2) = Rhs + 2;
+       //      }
+
+       //      C2F(putlhsvar)();
+
+       //      freeArrayOfString(ShortNames, m1n1);
+       //      if (bOK) {FREE(bOK); bOK = NULL;}
+       //}
+       //else
+       //{
+       //      Scierror(999,_("%s: Wrong type for input argument: A string expected.\n"),fname);
+       //}
+       //return 0;
+}
+/*--------------------------------------------------------------------------*/
index 7b50aa0..4c11c95 100644 (file)
@@ -16,6 +16,7 @@
 #include "MALLOC.h"
 #include "charEncoding.h"
 #include "os_strdup.h"
+#include "os_wcsdup.h"
 /*--------------------------------------------------------------------------*/
 #ifdef _MSC_VER
        #ifndef MAX_PATH_SHORT
@@ -98,3 +99,51 @@ char *getshortpathname(char *longpathname,BOOL *convertok)
        return ShortName;
 }
 /*--------------------------------------------------------------------------*/
+wchar_t* getshortpathnameW(wchar_t* _pwstLongPathName, BOOL* _pbOK)
+{
+    wchar_t* pwstOutput = NULL;
+    if(_pwstLongPathName)
+    {
+#ifdef _MSC_VER
+        int iLen = GetShortPathNameW(_pwstLongPathName, NULL, 0);
+
+        if(iLen <= 0)
+        {
+            iLen = MAX_PATH_SHORT;
+        }
+
+        pwstOutput = (wchar_t*)MALLOC((iLen + 1) * sizeof(wchar_t));
+
+        if(pwstOutput) 
+        {
+            /* second converts path */
+            if(GetShortPathNameW(_pwstLongPathName, pwstOutput, iLen))
+            {
+                *_pbOK = TRUE;
+            }
+            else
+            {
+                FREE(_pwstLongPathName);
+                pwstOutput = os_wcsdup(_pwstLongPathName);
+                *_pbOK = FALSE;
+            }
+        }
+        else
+        {
+            /* FAILED */
+            pwstOutput = os_wcsdup(_pwstLongPathName);
+            *_pbOK = FALSE;
+        }
+#else
+               /* Linux and MacOS*/
+        pwstOutput = os_wcsdup(_pwstLongPathName);
+               *_pbOK = FALSE;
+#endif
+    }
+    else
+    {
+        *_pbOK = FALSE;
+    }
+    return pwstOutput;
+}
+/*--------------------------------------------------------------------------*/