xpad manages expandable filename
Allan CORNET [Mon, 14 Sep 2009 12:30:07 +0000 (14:30 +0200)]
18 files changed:
scilab/Scilab.sln
scilab/Scilab_f2c.sln
scilab/modules/core/includes/setgetSCIpath.h
scilab/modules/core/includes/tmpdir.h
scilab/modules/core/src/c/setgetSCIpath.c
scilab/modules/core/src/c/tmpdir.c
scilab/modules/fileio/LibScilab_Import.def
scilab/modules/fileio/Makefile.am
scilab/modules/fileio/fileio.vcproj
scilab/modules/fileio/includes/expandPathVariable.h [new file with mode: 0644]
scilab/modules/fileio/io_Import.def
scilab/modules/fileio/src/c/cluni0.c
scilab/modules/fileio/src/c/expandPathVariable.c [new file with mode: 0644]
scilab/modules/xpad/Makefile.am
scilab/modules/xpad/sci_gateway/cpp/sci_xpad.cpp
scilab/modules/xpad/src/c/LibScilab_Import.def
scilab/modules/xpad/src/c/xpad.vcproj
scilab/modules/xpad/src/cpp/callxpad.cpp

index 706fdaf..d477a18 100644 (file)
@@ -1056,6 +1056,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xpad", "modules\xpad\src\c\xpad.vcproj", "{BAE68B54-2C1A-44D0-A0E9-05156A784E79}"
        ProjectSection(ProjectDependencies) = postProject
                {ECFFEB0C-1EDA-45EE-9A10-B18143852E17} = {ECFFEB0C-1EDA-45EE-9A10-B18143852E17}
+               {4FC72D4A-80EE-4B1A-8724-0201C1A35621} = {4FC72D4A-80EE-4B1A-8724-0201C1A35621}
                {53A01263-92BE-4C87-AA9A-79297F882310} = {53A01263-92BE-4C87-AA9A-79297F882310}
                {6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E} = {6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E}
                {8BA2DDA8-BD04-4D4D-8EE6-6CAA955F7470} = {8BA2DDA8-BD04-4D4D-8EE6-6CAA955F7470}
index 95d43ce..9e94698 100644 (file)
@@ -1057,6 +1057,7 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xpad", "modules\xpad\src\c\xpad.vcproj", "{BAE68B54-2C1A-44D0-A0E9-05156A784E79}"
        ProjectSection(ProjectDependencies) = postProject
                {ECFFEB0C-1EDA-45EE-9A10-B18143852E17} = {ECFFEB0C-1EDA-45EE-9A10-B18143852E17}
+               {4FC72D4A-80EE-4B1A-8724-0201C1A35621} = {4FC72D4A-80EE-4B1A-8724-0201C1A35621}
                {53A01263-92BE-4C87-AA9A-79297F882310} = {53A01263-92BE-4C87-AA9A-79297F882310}
                {6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E} = {6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E}
                {8BA2DDA8-BD04-4D4D-8EE6-6CAA955F7470} = {8BA2DDA8-BD04-4D4D-8EE6-6CAA955F7470}
index dbd54ec..85ab043 100644 (file)
@@ -9,6 +9,10 @@
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
+
+#ifndef __SETGETSCIPATH_H__
+#define __SETGETSCIPATH_H__
+
 /** 
  * save SCI path
  * @param path a char * in order to set the Scilab Path
 void setSCIpath(char *path);
 
 /** 
- * get SCI path
- * @return the path to Scilab
+* get SCI path
+* @return the path to Scilab
 */
 char *getSCIpath(void);
 
+/** 
+* get SCI path (wide string)
+* @return the path to Scilab
+*/
+wchar_t *getSCIpathW(void);
+
+#endif /* __SETGETSCIPATH_H__ */
 /*--------------------------------------------------------------------------*/ 
index 8532b7b..fbd1e10 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef __TMPDIR_H__
 #define __TMPDIR_H__
 
+#include <wchar.h>
+
 #include "machine.h"
 
 /**
@@ -29,13 +31,20 @@ void C2F(settmpdir)(void);
 void C2F(tmpdirc)(void);
 
 /**
- * @TODO add comment
- *
+ * returns TMPDIR directory value
  * @param void  
  * @return <ReturnValue>
  */
 char *getTMPDIR(void);
 
+
+/**
+* returns TMPDIR directory value (wide string)
+* @param void  
+* @return <ReturnValue>
+*/
+wchar_t *getTMPDIRW(void);
+
 #endif /* __TMPDIR_H__ */
 /*--------------------------------------------------------------------------*/ 
 
index a5ceff8..b829e60 100644 (file)
@@ -12,6 +12,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "charEncoding.h"
 #include "setgetSCIpath.h"
 #ifdef _MSC_VER
 #include "strdup_windows.h"
@@ -30,3 +31,8 @@ char *getSCIpath(void)
        return strdup(SCIPATH);
 }
 /*--------------------------------------------------------------------------*/ 
+wchar_t *getSCIpathW(void)
+{
+       return to_wide_string(SCIPATH);
+}
+/*--------------------------------------------------------------------------*/ 
\ No newline at end of file
index d1529db..69d9a17 100644 (file)
@@ -145,3 +145,8 @@ void C2F(tmpdirc)(void)
        removedir(tmp_dir);
 }
 /*--------------------------------------------------------------------------*/
+wchar_t *getTMPDIRW(void)
+{
+       return to_wide_string(tmp_dir);
+}
+/*--------------------------------------------------------------------------*/
\ No newline at end of file
index d18abfa..94abee9 100644 (file)
@@ -29,3 +29,5 @@ transposeMatrixDouble
 getScilabMode
 GetData
 freeArrayOfWideString
+getTMPDIRW
+getSCIpathW
\ No newline at end of file
index 0f11210..6b73f71 100644 (file)
@@ -45,6 +45,7 @@ src/c/fileinfo.c \
 src/c/getrelativefilename.c \
 src/c/splitpath.c \
 src/c/movefile.c \
+src/c/expandPathVariable.c \
 src/c/copyfile_others.c
 
 GATEWAY_SOURCES = \
@@ -166,6 +167,7 @@ includes/deleteafile.h \
 includes/readline.h \
 includes/splitpath.h \
 includes/cluni0.h \
+includes/expandPathVariable.h \
 includes/dynlib_fileio.h \
 includes/scicurdir.h
 
index d751bf5..a299033 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\src\c\expandPathVariable.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\src\c\FileExist.c"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath=".\includes\expandPathVariable.h"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\includes\FileExist.h"
                                >
                        </File>
diff --git a/scilab/modules/fileio/includes/expandPathVariable.h b/scilab/modules/fileio/includes/expandPathVariable.h
new file mode 100644 (file)
index 0000000..4274b76
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* 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
+*
+*/
+/*--------------------------------------------------------------------------*/
+#ifndef __EXPANDPATHVARIABLE_H__
+#define __EXPANDPATHVARIABLE_H__
+
+#include <wchar.h>
+#include "dynlib_fileio.h"
+
+/**
+* expanded variables are: 
+* "SCI/" "sci/" "$SCI" "SCI\\" "sci\\"
+* "HOME/"  "home/"  "~/" "HOME\\"  "home\\"  "~\\" "$HOME"
+* "TMPDIR/" "tmpdir/" "TMPDIR\\" "tmpdir\\"  "$TMPDIR"
+*
+* replace order SCI, HOME , TMPDIR
+*/
+
+/**
+* expand in_name to produce out_name 
+* @param[in] string where to find a variable and expand
+* @return string with expanded variable
+*/
+FILEIO_IMPEXP char *expandPathVariable(char* str);
+
+/**
+* expand in_name to produce out_name (wide string)
+* @param[in] wide string where to find a variable and expand
+* @return wide string with expanded variable
+*/
+FILEIO_IMPEXP wchar_t *expandPathVariableW(wchar_t *wcstr);
+
+#endif /* __EXPANDPATHVARIABLE_H__ */
+/*--------------------------------------------------------------------------*/
index 1fc799e..3abe4e8 100644 (file)
@@ -3,5 +3,6 @@ LIBRARY    io.dll
 
 EXPORTS
 GetenvB
+getenvc_
 setUpdateEnvVar
 getUpdateEnvVar
index 2406ec7..0c4c18d 100644 (file)
@@ -20,6 +20,7 @@
 #include "cluni0.h"
 #include "GetenvB.h"
 
+
 static char *SCI_a[]  = {  "SCI/"   , "sci/"   , "$SCI"   , "SCI\\"    , "sci\\"   , (char *) 0 };
 static char *HOME_a[] = {  "HOME/"  , "home/"  , "~/"     , "HOME\\"   , "home\\"  , "~\\" , "$HOME" , (char *) 0};
 static char *TMP_a[]  = {  "TMPDIR/", "tmpdir/","TMPDIR\\", "tmpdir\\" , "$TMPDIR" , (char *) 0};
diff --git a/scilab/modules/fileio/src/c/expandPathVariable.c b/scilab/modules/fileio/src/c/expandPathVariable.c
new file mode 100644 (file)
index 0000000..ce01dec
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* 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 "expandPathVariable.h"
+#include "charEncoding.h"
+#include "MALLOC.h"
+#include "PATH_MAX.h"
+#include "tmpdir.h"
+#include "setgetSCIpath.h"
+#include "getenvc.h"
+/*--------------------------------------------------------------------------*/
+static wchar_t *SCI_words[]  = 
+{
+       L"SCI/" ,
+       L"sci/" ,
+       L"$SCI" ,
+       L"SCI\\" ,
+       L"sci\\" ,
+       (wchar_t *) NULL
+};
+
+static wchar_t *HOME_words[] = 
+{
+       L"HOME/" ,
+       L"home/" ,
+       L"~/" ,
+       L"HOME\\" ,
+       L"home\\" ,
+       L"~\\" ,
+       L"$HOME" ,
+       (wchar_t *) NULL
+};
+
+static wchar_t *TMP_words[]  = 
+{
+       L"TMPDIR/" ,
+       L"tmpdir/" ,
+       L"TMPDIR\\" ,
+       L"tmpdir\\" ,
+       L"$TMPDIR" ,
+       (wchar_t *) NULL
+};
+/*--------------------------------------------------------------------------*/
+static wchar_t *SCIDIR = NULL;
+static wchar_t *TMPDIR = NULL;
+static wchar_t *HOMEDIR = NULL;
+/*--------------------------------------------------------------------------*/
+static wchar_t *findAliasInString(wchar_t *wcStr, wchar_t *wcAlias);
+static wchar_t *replaceAliasInString(wchar_t *wcValue, wchar_t *wcBegin);
+static wchar_t *getHomeDirW(void);
+static wchar_t *convertFileSeparators(wchar_t *wcStr);
+/*--------------------------------------------------------------------------*/
+wchar_t *expandPathVariableW(wchar_t *wcstr)
+{
+       int i = 0;
+
+       wchar_t *wcexpanded = NULL;
+       wchar_t *wcTmp = NULL;
+
+       if (wcstr == NULL) return wcexpanded;
+       if (SCIDIR == NULL) SCIDIR = getSCIpathW();
+       if (TMPDIR == NULL) TMPDIR = getTMPDIRW();
+       if (HOMEDIR == NULL) HOMEDIR = getHomeDirW();
+
+       i = 0;
+       while(SCI_words[i] != NULL)
+       {
+               wcTmp = findAliasInString(wcstr, SCI_words[i]);
+               if (wcTmp)
+               {
+                       return replaceAliasInString(SCIDIR, wcTmp);
+               }
+               i++;
+       }
+
+       i = 0;
+       while(HOME_words[i] != NULL)
+       {
+               wcTmp = findAliasInString(wcstr, HOME_words[i]);
+               if (wcTmp)
+               {
+                       return replaceAliasInString(HOMEDIR, wcTmp);
+               }
+               i++;
+       }
+
+       i = 0;
+       while(TMP_words[i] != NULL)
+       {
+               wcTmp = findAliasInString(wcstr, TMP_words[i]);
+               if (wcTmp)
+               {
+                       return replaceAliasInString(TMPDIR, wcTmp);
+               }
+               i++;
+       }
+       
+       /* Variables not founded returns a copy of input */
+       wcexpanded = (wchar_t*)MALLOC(sizeof(wchar_t)* ((int)wcslen(wcstr) + 1));
+       wcscpy(wcexpanded, wcstr);
+       return convertFileSeparators(wcexpanded);
+}
+/*--------------------------------------------------------------------------*/
+char *expandPathVariable(char* str)
+{
+       char *expanded = NULL;
+       wchar_t *wstr = to_wide_string(str);
+
+       if (wstr)
+       {
+               wchar_t *wcexpanded = expandPathVariableW(wstr);
+               if (wcexpanded)
+               {
+                       expanded = wide_string_to_UTF8(wcexpanded);
+                       FREE(wcexpanded);
+                       wcexpanded = NULL;
+               }
+               FREE(wstr);
+               wstr = NULL;
+       }
+       return expanded;
+}
+/*--------------------------------------------------------------------------*/
+static wchar_t *findAliasInString(wchar_t *wcStr, wchar_t *wcAlias)
+{
+       if (wcStr && wcAlias)
+       {
+               int lenwcAlias = (int)wcslen(wcAlias);
+               int lenwcStr = (int)wcslen(wcStr);
+               if (lenwcStr >= lenwcAlias)
+               {
+                       wchar_t *wcBegin = (wchar_t *)MALLOC(sizeof(wchar_t) * (lenwcAlias + 1));
+                       wcsncpy(wcBegin, wcStr, lenwcAlias);
+                       if (wcscmp(wcBegin, wcAlias) == 0)
+                       {
+                               FREE(wcBegin); wcBegin = NULL;
+                               return(&wcStr[lenwcAlias]);
+                       }
+                       FREE(wcBegin); wcBegin = NULL;
+               }
+       }
+       return NULL;
+}
+/*--------------------------------------------------------------------------*/
+static wchar_t *replaceAliasInString(wchar_t *wcValue, wchar_t *wcBegin)
+{
+       wchar_t *wcexpanded = NULL;
+       int lenwcBegin = (int)wcslen(wcBegin);
+       int lenwcValue = (int)wcslen(wcValue);
+
+       wcexpanded = (wchar_t*)MALLOC(sizeof(wchar_t) * (lenwcBegin + lenwcValue + 1 + 1));
+
+       wcscpy(wcexpanded, wcValue);
+       wcscat(wcexpanded, L"/");
+       wcscat(wcexpanded, wcBegin);
+
+       return convertFileSeparators(wcexpanded);
+}
+/*--------------------------------------------------------------------------*/
+static wchar_t *getHomeDirW(void)
+{
+       int ierr = 0;
+       char result[MAX_PATH];
+       int lenMAX = MAX_PATH;
+       int iflag = 0; /* no warnings */
+
+       C2F(getenvc)(&ierr, "home", result, &lenMAX, &iflag);
+       if (ierr == 0)
+       {
+               return to_wide_string(result);
+       }
+       return NULL;
+}
+/*--------------------------------------------------------------------------*/
+static wchar_t *convertFileSeparators(wchar_t *wcStr)
+{
+       if (wcStr)
+       {
+               int k = 0;
+               int len = (int)wcslen(wcStr);
+
+#ifdef _MSC_VER
+               for (k=0 ; k < len ;k++) if (wcStr[k] == L'/') wcStr[k] = L'\\';
+#else
+               for (k=0 ; k < len ;k++) if (wcStr[k] == L'\\') wcStr[k] = L'/';
+#endif
+       }
+       return wcStr;
+}
+/*--------------------------------------------------------------------------*/
index e2fdd58..07e6887 100644 (file)
@@ -50,6 +50,7 @@ libscixpad_la_CFLAGS= $(JAVA_JNI_INCLUDE) \
                        -I$(top_srcdir)/modules/output_stream/includes \
                        -I$(top_srcdir)/modules/localization/includes \
                        -I$(top_srcdir)/modules/api_scilab/includes \
+                       -I$(top_srcdir)/modules/fileio/includes \
                        -I$(top_srcdir)/modules/core/includes \
                        -I$(top_srcdir)/modules/functions/includes
 
index 90bc6bf..72c9886 100644 (file)
@@ -13,6 +13,7 @@
 
 extern "C"
 {
+#include <wchar.h>
 #include "callxpad.h"
 #include "gw_xpad.h"
 #include "stack-c.h"
@@ -38,7 +39,7 @@ int sci_xpad(char *fname,unsigned long fname_len)
        {
                int m1 = 0, n1 = 0;
                int *piAddressVarOne = NULL;
-               char **pStVarOne = NULL;
+               wchar_t **pStVarOne = NULL;
                int *lenStVarOne = NULL;
                int i = 0;
 
@@ -51,7 +52,7 @@ int sci_xpad(char *fname,unsigned long fname_len)
                }
 
                /* get dimensions */
-               getMatrixOfString(piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
+               getMatrixOfWideString(piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
 
                lenStVarOne = (int*)MALLOC(sizeof(int)*(m1 * n1));
                if (lenStVarOne == NULL)
@@ -61,9 +62,9 @@ int sci_xpad(char *fname,unsigned long fname_len)
                }
 
                /* get lengths */
-               getMatrixOfString(piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
+               getMatrixOfWideString(piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
 
-               pStVarOne = (char **)MALLOC(sizeof(char*)*(m1*n1));
+               pStVarOne = (wchar_t  **)MALLOC(sizeof(wchar_t *)*(m1*n1));
                if (pStVarOne == NULL)
                {
                        Scierror(999,_("%s: No more memory.\n"), fname);
@@ -72,14 +73,14 @@ int sci_xpad(char *fname,unsigned long fname_len)
 
                for(i = 0; i < m1 * n1; i++)
                {
-                       pStVarOne[i] = (char*)MALLOC(sizeof(char*) * (lenStVarOne[i] + 1));
+                       pStVarOne[i] = (wchar_t *)MALLOC(sizeof(wchar_t *) * (lenStVarOne[i] + 1));
                }
   
                /* get strings */
-               getMatrixOfString(piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
+               getMatrixOfWideString(piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
 
-               callXpad(pStVarOne,m1 * n1);
-               freeArrayOfString(pStVarOne,m1 * n1);
+               callXpadW(pStVarOne,m1 * n1);
+               freeArrayOfWideString(pStVarOne,m1 * n1);
        }
 
        LhsVar(1) = 0;
index 992e074..d3cd1a9 100644 (file)
@@ -14,6 +14,7 @@ vartype_
 checkrhs_ 
 checklhs_
 freeArrayOfString
+freeArrayOfWideString
 getVariablesName
 getcommandkeywords
 GetFunctionsList
\ No newline at end of file
index 7327cbe..bc04808 100644 (file)
@@ -44,7 +44,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories=".;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../../libs/MALLOC/includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes"
+                               AdditionalIncludeDirectories=".;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../../libs/MALLOC/includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes;../../../fileio/includes"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;XPAD_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories=".;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../../libs/MALLOC/includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes"
+                               AdditionalIncludeDirectories=".;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../../libs/MALLOC/includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes;../../../fileio/includes"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;XPAD_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories=".;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../../libs/MALLOC/includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes"
+                               AdditionalIncludeDirectories=".;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../../libs/MALLOC/includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes;../../../fileio/includes"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;XPAD_EXPORTS"
                                StringPooling="true"
                                RuntimeLibrary="2"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories=".;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../../libs/MALLOC/includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes"
+                               AdditionalIncludeDirectories=".;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../../libs/MALLOC/includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes;../../../fileio/includes"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;XPAD_EXPORTS"
                                StringPooling="true"
                                RuntimeLibrary="2"
index 0ed291d..68dc06e 100644 (file)
@@ -20,6 +20,7 @@ extern "C"
 #include "charEncoding.h"
 #include "MALLOC.h"
 #include "freeArrayOfString.h"
+#include "expandPathVariable.h"
 }
 /*--------------------------------------------------------------------------*/
 using namespace org_scilab_modules_xpad;
@@ -31,7 +32,16 @@ int callXpad(char **_filenames, int _nbfiles)
                int i = 0;
                for (i = 0; i < _nbfiles; i++)
                {
-                       Xpad::xpad(getScilabJavaVM(), _filenames[i]);
+                       char *filename = expandPathVariable( _filenames[i]);
+                       if (filename)
+                       {
+                               Xpad::xpad(getScilabJavaVM(), filename);
+                               FREE(filename); filename = NULL;
+                       }
+                       else
+                       {
+                               Xpad::xpad(getScilabJavaVM());
+                       }
                }
        }
        else
@@ -51,7 +61,9 @@ int callXpadW(wchar_t **_wcfilenames, int _nbfiles)
                {
                        for (i = 0; i < _nbfiles; i++)
                        {
-                               filesname[i] = wide_string_to_UTF8(_wcfilenames[i]);
+                               wchar_t *wcfilename = expandPathVariableW(_wcfilenames[i]);
+                               filesname[i] = wide_string_to_UTF8(wcfilename);
+                               if (wcfilename) {FREE(wcfilename); wcfilename = NULL;}
                        }
                        callXpad(filesname, _nbfiles);
                        freeArrayOfString(filesname, _nbfiles);