convert pathconvert, add home variable 84/1784/5
antoine ELIAS [Thu, 2 Sep 2010 12:17:10 +0000 (14:17 +0200)]
Change-Id: I31e32cbc5de3d93933e242044eae68d9df2954b8

19 files changed:
scilab/modules/development_tools/macros/test_run.sci
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/gw_fileio.h
scilab/modules/fileio/sci_gateway/c/sci_pathconvert.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_pathconvert.cpp [new file with mode: 0644]
scilab/modules/fileio/src/c/pathconvert.h
scilab/modules/system_env/Makefile.am
scilab/modules/system_env/Makefile.in
scilab/modules/system_env/includes/configvariable.hxx
scilab/modules/system_env/includes/home.h [new file with mode: 0644]
scilab/modules/system_env/src/cpp/configvariable.cpp
scilab/modules/system_env/src/cpp/home.cpp [new file with mode: 0644]
scilab/modules/system_env/src/cpp/setenvvar.cpp
scilab/modules/system_env/system_env.vcproj

index a89ba99..875d35c 100644 (file)
@@ -168,8 +168,8 @@ function test_run(varargin)
        // Stacksize management
        // =======================================================
 
-       gstacksize(10000000);
-       stacksize(10000000);
+       //gstacksize(10000000);
+       //stacksize(10000000);
 
        // =======================================================
        // Gestion des tests à lancer
@@ -219,6 +219,7 @@ function test_run(varargin)
                        if with_module(module.items(1)) then
                                module = module_set_path(module,pathconvert(SCI+"/modules/"+module.items(1),%F));
 
+
                                // It's an external module
                        elseif isdir(module.items(1)) then
                                module = module_set_path(module,pathconvert(module.items(1),%F));
@@ -515,6 +516,7 @@ function directories = get_directories(directory)
 
        this_directory_type   = directory.type;
 
+
        directories           = list();
        directories($+1)      = directory;
 
index ee4c8b2..2993204 100644 (file)
@@ -86,7 +86,6 @@ sci_gateway/c/sci_copyfile.c \
 sci_gateway/c/sci_fileparts.c \
 sci_gateway/c/sci_movefile.c \
 sci_gateway/c/sci_basename.c \
-sci_gateway/c/sci_pathconvert.c \
 sci_gateway/c/sci_isfile.c
 
 GATEWAY_CPP_SOURCES = \
@@ -96,7 +95,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_mget.cpp \
        sci_gateway/cpp/sci_mput.cpp \
        sci_gateway/cpp/sci_mputl.cpp \
-       sci_gateway/cpp/sci_mgetl.cpp
+       sci_gateway/cpp/sci_mgetl.cpp \
+       sci_gateway/cpp/sci_pathconvert.cpp
 
 FILEIO_CPP_SOURCES = \
        src/cpp/expandPathVariable.cpp \
index b7634b6..c047ed9 100644 (file)
@@ -175,13 +175,12 @@ am__objects_3 = libscifileio_la-gw_fileio.lo \
        libscifileio_la-sci_copyfile.lo \
        libscifileio_la-sci_fileparts.lo \
        libscifileio_la-sci_movefile.lo \
-       libscifileio_la-sci_basename.lo \
-       libscifileio_la-sci_pathconvert.lo \
-       libscifileio_la-sci_isfile.lo
+       libscifileio_la-sci_basename.lo libscifileio_la-sci_isfile.lo
 am__objects_4 = libscifileio_la-fileio_gw.lo \
        libscifileio_la-sci_mopen.lo libscifileio_la-sci_mclose.lo \
        libscifileio_la-sci_mget.lo libscifileio_la-sci_mput.lo \
-       libscifileio_la-sci_mputl.lo libscifileio_la-sci_mgetl.lo
+       libscifileio_la-sci_mputl.lo libscifileio_la-sci_mgetl.lo \
+       libscifileio_la-sci_pathconvert.lo
 am_libscifileio_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
        $(am__objects_3) $(am__objects_4)
 libscifileio_la_OBJECTS = $(am_libscifileio_la_OBJECTS)
@@ -549,7 +548,6 @@ sci_gateway/c/sci_copyfile.c \
 sci_gateway/c/sci_fileparts.c \
 sci_gateway/c/sci_movefile.c \
 sci_gateway/c/sci_basename.c \
-sci_gateway/c/sci_pathconvert.c \
 sci_gateway/c/sci_isfile.c
 
 GATEWAY_CPP_SOURCES = \
@@ -559,7 +557,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_mget.cpp \
        sci_gateway/cpp/sci_mput.cpp \
        sci_gateway/cpp/sci_mputl.cpp \
-       sci_gateway/cpp/sci_mgetl.cpp
+       sci_gateway/cpp/sci_mgetl.cpp \
+       sci_gateway/cpp/sci_pathconvert.cpp
 
 FILEIO_CPP_SOURCES = \
        src/cpp/expandPathVariable.cpp \
@@ -1445,13 +1444,6 @@ libscifileio_la-sci_basename.lo: sci_gateway/c/sci_basename.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_basename.lo `test -f 'sci_gateway/c/sci_basename.c' || echo '$(srcdir)/'`sci_gateway/c/sci_basename.c
 
-libscifileio_la-sci_pathconvert.lo: sci_gateway/c/sci_pathconvert.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_pathconvert.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_pathconvert.Tpo -c -o libscifileio_la-sci_pathconvert.lo `test -f 'sci_gateway/c/sci_pathconvert.c' || echo '$(srcdir)/'`sci_gateway/c/sci_pathconvert.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_pathconvert.Tpo $(DEPDIR)/libscifileio_la-sci_pathconvert.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_pathconvert.c' object='libscifileio_la-sci_pathconvert.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_pathconvert.lo `test -f 'sci_gateway/c/sci_pathconvert.c' || echo '$(srcdir)/'`sci_gateway/c/sci_pathconvert.c
-
 libscifileio_la-sci_isfile.lo: sci_gateway/c/sci_isfile.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_isfile.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_isfile.Tpo -c -o libscifileio_la-sci_isfile.lo `test -f 'sci_gateway/c/sci_isfile.c' || echo '$(srcdir)/'`sci_gateway/c/sci_isfile.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_isfile.Tpo $(DEPDIR)/libscifileio_la-sci_isfile.Plo
@@ -1585,6 +1577,13 @@ libscifileio_la-sci_mgetl.lo: sci_gateway/cpp/sci_mgetl.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_mgetl.lo `test -f 'sci_gateway/cpp/sci_mgetl.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_mgetl.cpp
 
+libscifileio_la-sci_pathconvert.lo: sci_gateway/cpp/sci_pathconvert.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_pathconvert.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_pathconvert.Tpo -c -o libscifileio_la-sci_pathconvert.lo `test -f 'sci_gateway/cpp/sci_pathconvert.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_pathconvert.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-sci_pathconvert.Tpo $(DEPDIR)/libscifileio_la-sci_pathconvert.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_pathconvert.cpp' object='libscifileio_la-sci_pathconvert.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_pathconvert.lo `test -f 'sci_gateway/cpp/sci_pathconvert.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_pathconvert.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index b47a142..1ce4fec 100644 (file)
                                >
                        </File>
                        <File
-                               RelativePath=".\sci_gateway\c\sci_pathconvert.c"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\sci_gateway\c\sci_pathsep.c"
                                >
                        </File>
index 256b78b..1e8de0a 100644 (file)
@@ -42,5 +42,6 @@ CPP_GATEWAY_PROTOTYPE(sci_mput);
 CPP_GATEWAY_PROTOTYPE(sci_mget);
 CPP_GATEWAY_PROTOTYPE(sci_mputl);
 CPP_GATEWAY_PROTOTYPE(sci_mgetl);
+CPP_GATEWAY_PROTOTYPE(sci_pathconvert);
 
 #endif /* !__FILEIO_GW_HXX__ */
index fb25024..3b5ede9 100644 (file)
 FILEIO_IMPEXP int gw_fileio(void);
 /*--------------------------------------------------------------------------*/ 
 FILEIO_IMPEXP int sci_meof(char *fname,unsigned long fname_len);
-//FILEIO_IMPEXP int sci_mopen(char *fname,unsigned long fname_len);
-//FILEIO_IMPEXP int sci_mclose(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_merror(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_mputstr(char *fname,unsigned long fname_len);
-//FILEIO_IMPEXP int sci_mput(char *fname,unsigned long fname_len);
-//FILEIO_IMPEXP int sci_mget(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_mgetstr(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_mseek(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_mtell(char *fname,unsigned long fname_len);
@@ -50,7 +46,6 @@ FILEIO_IMPEXP int sci_fileinfo(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_newest(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_getrelativefilename(char *fname, unsigned long l);
 FILEIO_IMPEXP int sci_get_absolute_file_path(char *fname,unsigned long fname_len);
-//FILEIO_IMPEXP int sci_mgetl(char *fname,unsigned long fname_len);
 
 //YaSp
 FILEIO_IMPEXP int sci_pwd(char *fname, int* _piKey);
@@ -60,7 +55,6 @@ FILEIO_IMPEXP int sci_copyfile(char *fname,int* _piKey);
 FILEIO_IMPEXP int sci_fileparts(char *fname, int* _piKey);
 FILEIO_IMPEXP int sci_movefile(char *fname, int* _piKey);
 FILEIO_IMPEXP int sci_basename(char *fname, int* _piKey);
-FILEIO_IMPEXP int sci_pathconvert(char *fname, int* _piKey);
 FILEIO_IMPEXP int sci_isfile(char *fname, int* _piKey);
 
 /*--------------------------------------------------------------------------*/ 
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_pathconvert.c b/scilab/modules/fileio/sci_gateway/c/sci_pathconvert.c
deleted file mode 100644 (file)
index 263d684..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
-* 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 "gw_fileio.h"
-#include "stack-c.h"
-#include "MALLOC.h"
-#include "localization.h"
-#include "api_scilab.h"
-#include "Scierror.h"
-#include "pathconvert.h"
-#include "freeArrayOfString.h"
-/*--------------------------------------------------------------------------*/
-int sci_pathconvert(char *fname, int* _piKey)
-{
-       SciErr sciErr;
-       int *piAddressVarOne = NULL;
-       wchar_t **pStVarOne = NULL;
-       int iType1 = 0;
-       int *lenStVarOne = NULL;
-       int m1 = 0, n1 = 0;
-
-       wchar_t **results = NULL;
-       int i = 0;
-
-       BOOL flagtrail = TRUE;
-       BOOL flagexpand = TRUE;
-
-       PathConvertType PType = AUTO_STYLE;
-
-       /* Check Input & Output parameters */
-       CheckRhs(1,4);
-       CheckLhs(1,1);
-
-
-       if (Rhs > 3)
-       {
-               int *piAddressVarFour = NULL;
-               wchar_t *pStVarFour = NULL;
-               int iType4 = 0;
-               int lenStVarFour = 0;
-               int m4 = 0, n4 = 0;
-
-               sciErr = getVarAddressFromPosition(_piKey, 4, &piAddressVarFour);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               sciErr = getVarType(_piKey, piAddressVarFour, &iType4);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               if (iType4 != sci_strings)
-               {
-                       Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 4);
-                       return 0;
-               }
-
-               sciErr = getVarDimension(_piKey, piAddressVarFour, &m4, &n4);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               if ( (m4 != n4) && (n4 != 1) ) 
-               {
-                       Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 4);
-                       return 0;
-               }
-
-               sciErr = getMatrixOfWideString(_piKey, piAddressVarFour, &m4, &n4, &lenStVarFour, &pStVarFour);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               pStVarFour = (wchar_t*)MALLOC(sizeof(wchar_t)*(lenStVarFour + 1));
-               if (pStVarFour == NULL)
-               {
-                       Scierror(999,_("%s: Memory allocation error.\n"),fname);
-                       return 0;
-               }
-
-               sciErr = getMatrixOfWideString(_piKey, piAddressVarFour, &m4, &n4, &lenStVarFour, &pStVarFour);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-
-               if ( (wcscmp(pStVarFour, L"w") == 0) || (wcscmp(pStVarFour, L"u") == 0) )
-               {
-                       if (wcscmp(pStVarFour, L"w") == 0)
-                       {
-                               PType = WINDOWS_STYLE;
-                       }
-                       else
-                       {
-                               PType = UNIX_STYLE;
-                       }
-                       if (pStVarFour) {FREE(pStVarFour); pStVarFour = NULL;}
-               }
-               else
-               {
-                       if (pStVarFour) {FREE(pStVarFour); pStVarFour = NULL;}
-                       Scierror(999,_("%s: Wrong value for input argument #%d: ''w'' or ''u'' string expected.\n"), fname, 4);
-                       return 0;
-               }
-       }
-
-       if (Rhs > 2)
-       {
-               int *piAddressVarThree = NULL;
-               int *piData = NULL;
-               int iType3      = 0;
-               int m3 = 0, n3 = 0;
-
-               sciErr = getVarAddressFromPosition(_piKey, 3, &piAddressVarThree);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               sciErr = getVarType(_piKey, piAddressVarThree, &iType3);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               if (iType3 != sci_boolean)
-               {
-                       Scierror(999,_("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 3);
-                       return 0;
-               }
-
-               sciErr = getVarDimension(_piKey, piAddressVarThree, &m3, &n3);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-
-               if ( (m3 != n3) && (n3 != 1) ) 
-               {
-                       Scierror(999,_("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 3);
-                       return 0;
-               }
-
-               sciErr = getMatrixOfBoolean(_piKey, piAddressVarThree, &m3, &n3,  &piData);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               flagexpand = piData[0];
-       }
-
-       if (Rhs > 1)
-       {
-               int *piAddressVarTwo = NULL;
-               int *piData = NULL;
-               int iType2      = 0;
-               int m2 = 0, n2 = 0;
-
-               sciErr = getVarAddressFromPosition(_piKey, 2, &piAddressVarTwo);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               sciErr = getVarType(_piKey, piAddressVarTwo, &iType2);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               if (iType2 != sci_boolean)
-               {
-                       Scierror(999,_("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 2);
-                       return 0;
-               }
-
-               sciErr = getVarDimension(_piKey, piAddressVarTwo, &m2, &n2);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               if ( (m2 != n2) && (n2 != 1) ) 
-               {
-                       Scierror(999,_("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 2);
-                       return 0;
-               }
-
-               sciErr = getMatrixOfBoolean(_piKey, piAddressVarTwo, &m2, &n2,  &piData);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               flagtrail = piData[0];
-       }
-
-       sciErr = getVarAddressFromPosition(_piKey, 1, &piAddressVarOne);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       sciErr = getVarType(_piKey, piAddressVarOne, &iType1);
-       if(sciErr.iErr)
-       {
-               printError(&sciErr, 0);
-               return 0;
-       }
-
-       if (iType1 == sci_matrix)
-       {
-               sciErr = getVarDimension(_piKey, piAddressVarOne, &m1, &n1);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               if ( (m1 == n1) && (m1 == 0) )
-               {
-                       sciErr = createMatrixOfDouble(_piKey, Rhs + 1, m1, n1, NULL);
-                       if(sciErr.iErr)
-                       {
-                               printError(&sciErr, 0);
-                               return 0;
-                       }
-
-                       LhsVar(1) = Rhs + 1;
-                       C2F(putlhsvar)();
-               }
-               else
-               {
-                       Scierror(999,_("%s: Wrong type for input argument #%d: String array expected.\n"), fname, 1);
-               }
-       }
-       else if (iType1 == sci_strings)
-       {
-               sciErr = getVarDimension(_piKey, piAddressVarOne, &m1, &n1);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               lenStVarOne = (int*)MALLOC(sizeof(int) * (m1 * n1));
-               if (lenStVarOne == NULL)
-               {
-                       Scierror(999,_("%s: Memory allocation error.\n"),fname);
-                       return 0;
-               }
-
-               results = (wchar_t **)MALLOC(sizeof(wchar_t*) * (m1 * n1));
-
-               if (results == NULL)
-               {
-                       if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
-                       freeArrayOfWideString(pStVarOne, m1 * n1);
-                       Scierror(999,_("%s: Memory allocation error.\n"),fname);
-                       return 0;
-               }
-
-               sciErr = getMatrixOfWideString(_piKey, piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               pStVarOne = (wchar_t**)MALLOC(sizeof(wchar_t*) * (m1 * n1));
-               if (pStVarOne == NULL)
-               {
-                       if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
-                       Scierror(999,_("%s: Memory allocation error.\n"),fname);
-                       return 0;
-               }
-
-               for( i = 0; i < m1 * n1; i++)
-               {
-                       pStVarOne[i] = (wchar_t*)MALLOC(sizeof(wchar_t)*(lenStVarOne[i] + 1));
-                       if (pStVarOne[i] == NULL)
-                       {
-                               if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
-                               freeArrayOfWideString(pStVarOne, m1 * n1);
-                               Scierror(999,_("%s: Memory allocation error.\n"),fname);
-                               return 0;
-                       }
-               }
-
-               sciErr = getMatrixOfWideString(_piKey, piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               for( i = 0; i < m1 * n1; i++)
-               {
-                       results[i] = pathconvertW(pStVarOne[i], flagtrail, flagexpand, PType);
-               }
-
-               sciErr = createMatrixOfWideString(_piKey, Rhs + 1, m1, n1, results);
-               if(sciErr.iErr)
-               {
-                       printError(&sciErr, 0);
-                       return 0;
-               }
-
-               LhsVar(1) = Rhs + 1;
-               C2F(putlhsvar)();
-
-               if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
-               freeArrayOfWideString(results, m1 * n1);
-               freeArrayOfWideString(pStVarOne, m1 * n1);
-       }
-       else
-       {
-               Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
-               return 0;
-       }
-       return 0;
-}
-/*--------------------------------------------------------------------------*/
index 3575ff0..5dc1f41 100644 (file)
@@ -31,5 +31,6 @@ bool FileioModule::Load()
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"mget", &sci_mget, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"mputl", &sci_mputl, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"mgetl", &sci_mgetl, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"pathconvert", &sci_pathconvert, MODULE_NAME));
     return true;
 }
index c5a02ba..d9e34b9 100644 (file)
@@ -44,7 +44,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../symbol/includes;../../../api_scilab/includes;../../../operations/includes;../../../localization/includes;../../../output_stream/includes;../../../../libs/intl;../../../../libs/MALLOC/includes;../../../system_env/includes;../../../string/includes;../../../windows_tools/includes;../../src/cpp"
+                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../functions_manager/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../symbol/includes;../../../api_scilab/includes;../../../operations/includes;../../../localization/includes;../../../output_stream/includes;../../../../libs/intl;../../../../libs/MALLOC/includes;../../../system_env/includes;../../../string/includes;../../../windows_tools/includes;../../src/cpp"
                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FILEIO_GW_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="3"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../symbol/includes;../../../api_scilab/includes;../../../operations/includes;../../../localization/includes;../../../output_stream/includes;../../../../libs/intl;../../../../libs/MALLOC/includes;../../../system_env/includes;../../../string/includes;../../../windows_tools/includes;../../src/cpp"
+                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../functions_manager/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../symbol/includes;../../../api_scilab/includes;../../../operations/includes;../../../localization/includes;../../../output_stream/includes;../../../../libs/intl;../../../../libs/MALLOC/includes;../../../system_env/includes;../../../string/includes;../../../windows_tools/includes;../../src/cpp"
                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FILEIO_GW_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="3"
                                Name="VCCLCompilerTool"
                                Optimization="2"
                                EnableIntrinsicFunctions="true"
-                               AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../symbol/includes;../../../api_scilab/includes;../../../operations/includes;../../../localization/includes;../../../output_stream/includes;../../../../libs/intl;../../../../libs/MALLOC/includes;../../../system_env/includes;../../../string/includes;../../../windows_tools/includes;../../src/cpp"
+                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../functions_manager/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../symbol/includes;../../../api_scilab/includes;../../../operations/includes;../../../localization/includes;../../../output_stream/includes;../../../../libs/intl;../../../../libs/MALLOC/includes;../../../system_env/includes;../../../string/includes;../../../windows_tools/includes;../../src/cpp"
                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FILEIO_GW_EXPORTS"
                                RuntimeLibrary="2"
                                EnableFunctionLevelLinking="true"
                                Name="VCCLCompilerTool"
                                Optimization="2"
                                EnableIntrinsicFunctions="true"
-                               AdditionalIncludeDirectories="../../includes;../../../functions_manager/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../symbol/includes;../../../api_scilab/includes;../../../operations/includes;../../../localization/includes;../../../output_stream/includes;../../../../libs/intl;../../../../libs/MALLOC/includes;../../../system_env/includes;../../../string/includes;../../../windows_tools/includes;../../src/cpp"
+                               AdditionalIncludeDirectories="../../includes;../../src/c;../../../functions_manager/includes;../../../types/includes;../../../core/includes;../../../abstractSyntaxTree/includes;../../../symbol/includes;../../../api_scilab/includes;../../../operations/includes;../../../localization/includes;../../../output_stream/includes;../../../../libs/intl;../../../../libs/MALLOC/includes;../../../system_env/includes;../../../string/includes;../../../windows_tools/includes;../../src/cpp"
                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FILEIO_GW_EXPORTS"
                                RuntimeLibrary="2"
                                EnableFunctionLevelLinking="true"
                                RelativePath=".\sci_mputl.cpp"
                                >
                        </File>
+                       <File
+                               RelativePath=".\sci_pathconvert.cpp"
+                               >
+                       </File>
                </Filter>
                <Filter
                        Name="Header Files"
diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_pathconvert.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_pathconvert.cpp
new file mode 100644 (file)
index 0000000..62b7808
--- /dev/null
@@ -0,0 +1,447 @@
+/*
+* 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 "funcmanager.hxx"
+#include "filemanager.hxx"
+#include "fileio_gw.hxx"
+
+extern "C"
+{
+#include "MALLOC.h"
+#include "localization.h"
+#include "Scierror.h"
+#include "pathconvert.h"
+}
+
+#define UNIX_TYPE       L"u"
+#define WINDOWS_TYPE    L"w"
+/*--------------------------------------------------------------------------*/
+Function::ReturnValue sci_pathconvert(typed_list &in, int _iRetCount, typed_list &out)
+{
+       PathConvertType PType   = AUTO_STYLE;
+    int iPathExpand         = 1;
+    int iPathTrail          = 1;
+
+    if(in.size() < 1 && in.size() > 4)
+    {
+        ScierrorW(999, _W("%ls: Wrong number of input arguments: %d to %d expected.\n"), L"pathconvert" , 1, 4);
+        return Function::Error;
+    }
+
+    if(_iRetCount != 1)
+    {
+        ScierrorW(78,_W("%ls: Wrong number of output argument(s): %d expected.\n"), L"pathconvert", 1);
+        return Function::Error;
+    }
+
+    //get type
+    if(in.size() > 3)
+    {
+        if(in[3]->isString() == false || in[3]->getAsString()->size_get() != 1)
+        {
+            ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A string expected.\n"), L"pathconvert", 4);
+            return Function::Error;
+        }
+
+        wchar_t* pwstType = in[3]->getAsString()->string_get(0);
+        if(wcscmp(pwstType, WINDOWS_TYPE) == 0)
+        {
+            PType = WINDOWS_STYLE;
+        }
+        else if(wcscmp(pwstType, UNIX_TYPE) == 0)
+        {
+            PType = UNIX_STYLE;
+        }
+        else
+        {
+            ScierrorW(999,_W("%ls: Wrong value for input argument #%d: '%ls' or '%ls' expected.\n"), L"pathconvert", 4, UNIX_TYPE, WINDOWS_TYPE);
+            return Function::Error;
+        }
+    }
+
+    if(in.size() > 2)
+    {
+        if(in[2]->isBool() == false || in[2]->getAsBool()->size_get() != 1)
+        {
+            ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A boolean expected.\n"), L"pathconvert", 3);
+            return Function::Error;
+        }
+
+        iPathExpand = in[2]->getAsBool()->bool_get()[0];
+    }
+
+    if(in.size() > 1)
+    {
+        if(in[1]->isBool() == false || in[1]->getAsBool()->size_get() != 1)
+        {
+            ScierrorW(999, _W("%ls: Wrong type for input argument #%d: A boolean expected.\n"), L"pathconvert", 2);
+            return Function::Error;
+        }
+
+        iPathTrail = in[1]->getAsBool()->bool_get()[0];
+    }
+
+    if(in[0]->isDouble() && in[0]->getAsDouble()->isEmpty())
+    {
+        out.push_back(Double::Empty());
+        return Function::OK;
+    }
+
+    if(in[0]->isString() == false)
+    {
+        ScierrorW(999, _W("%ls: Wrong type for input argument #%d: Matrix of strings expected.\n"), L"pathconvert", 1);
+        return Function::Error;
+    }
+
+    String* pS      = in[0]->getAsString();
+    String* pOut    = new String(pS->rows_get(), pS->cols_get());
+    wchar_t** pStr  = pOut->string_get();
+
+
+    for(int i = 0 ; i < pS->size_get() ; i++)
+    {
+        pStr[i] = pathconvertW(pS->string_get(i), iPathTrail, iPathExpand, PType);
+    }
+
+    out.push_back(pOut);
+    return Function::OK;
+       //SciErr sciErr;
+       //int *piAddressVarOne = NULL;
+       //wchar_t **pStVarOne = NULL;
+       //int iType1 = 0;
+       //int *lenStVarOne = NULL;
+       //int m1 = 0, n1 = 0;
+
+       //wchar_t **results = NULL;
+       //int i = 0;
+
+       //BOOL flagtrail = TRUE;
+       //BOOL flagexpand = TRUE;
+
+       //PathConvertType PType = AUTO_STYLE;
+
+       ///* Check Input & Output parameters */
+       //CheckRhs(1,4);
+       //CheckLhs(1,1);
+
+
+       //if (Rhs > 3)
+       //{
+       //      int *piAddressVarFour = NULL;
+       //      wchar_t *pStVarFour = NULL;
+       //      int iType4 = 0;
+       //      int lenStVarFour = 0;
+       //      int m4 = 0, n4 = 0;
+
+       //      sciErr = getVarAddressFromPosition(_piKey, 4, &piAddressVarFour);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      sciErr = getVarType(_piKey, piAddressVarFour, &iType4);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      if (iType4 != sci_strings)
+       //      {
+       //              Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 4);
+       //              return 0;
+       //      }
+
+       //      sciErr = getVarDimension(_piKey, piAddressVarFour, &m4, &n4);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      if ( (m4 != n4) && (n4 != 1) ) 
+       //      {
+       //              Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 4);
+       //              return 0;
+       //      }
+
+       //      sciErr = getMatrixOfWideString(_piKey, piAddressVarFour, &m4, &n4, &lenStVarFour, &pStVarFour);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      pStVarFour = (wchar_t*)MALLOC(sizeof(wchar_t)*(lenStVarFour + 1));
+       //      if (pStVarFour == NULL)
+       //      {
+       //              Scierror(999,_("%s: Memory allocation error.\n"),fname);
+       //              return 0;
+       //      }
+
+       //      sciErr = getMatrixOfWideString(_piKey, piAddressVarFour, &m4, &n4, &lenStVarFour, &pStVarFour);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+
+       //      if ( (wcscmp(pStVarFour, L"w") == 0) || (wcscmp(pStVarFour, L"u") == 0) )
+       //      {
+       //              if (wcscmp(pStVarFour, L"w") == 0)
+       //              {
+       //                      PType = WINDOWS_STYLE;
+       //              }
+       //              else
+       //              {
+       //                      PType = UNIX_STYLE;
+       //              }
+       //              if (pStVarFour) {FREE(pStVarFour); pStVarFour = NULL;}
+       //      }
+       //      else
+       //      {
+       //              if (pStVarFour) {FREE(pStVarFour); pStVarFour = NULL;}
+       //              Scierror(999,_("%s: Wrong value for input argument #%d: ''w'' or ''u'' string expected.\n"), fname, 4);
+       //              return 0;
+       //      }
+       //}
+
+       //if (Rhs > 2)
+       //{
+       //      int *piAddressVarThree = NULL;
+       //      int *piData = NULL;
+       //      int iType3      = 0;
+       //      int m3 = 0, n3 = 0;
+
+       //      sciErr = getVarAddressFromPosition(_piKey, 3, &piAddressVarThree);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      sciErr = getVarType(_piKey, piAddressVarThree, &iType3);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      if (iType3 != sci_boolean)
+       //      {
+       //              Scierror(999,_("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 3);
+       //              return 0;
+       //      }
+
+       //      sciErr = getVarDimension(_piKey, piAddressVarThree, &m3, &n3);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+
+       //      if ( (m3 != n3) && (n3 != 1) ) 
+       //      {
+       //              Scierror(999,_("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 3);
+       //              return 0;
+       //      }
+
+       //      sciErr = getMatrixOfBoolean(_piKey, piAddressVarThree, &m3, &n3,  &piData);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      flagexpand = piData[0];
+       //}
+
+       //if (Rhs > 1)
+       //{
+       //      int *piAddressVarTwo = NULL;
+       //      int *piData = NULL;
+       //      int iType2      = 0;
+       //      int m2 = 0, n2 = 0;
+
+       //      sciErr = getVarAddressFromPosition(_piKey, 2, &piAddressVarTwo);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      sciErr = getVarType(_piKey, piAddressVarTwo, &iType2);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      if (iType2 != sci_boolean)
+       //      {
+       //              Scierror(999,_("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 2);
+       //              return 0;
+       //      }
+
+       //      sciErr = getVarDimension(_piKey, piAddressVarTwo, &m2, &n2);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      if ( (m2 != n2) && (n2 != 1) ) 
+       //      {
+       //              Scierror(999,_("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 2);
+       //              return 0;
+       //      }
+
+       //      sciErr = getMatrixOfBoolean(_piKey, piAddressVarTwo, &m2, &n2,  &piData);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      flagtrail = piData[0];
+       //}
+
+       //sciErr = getVarAddressFromPosition(_piKey, 1, &piAddressVarOne);
+       //if(sciErr.iErr)
+       //{
+       //      printError(&sciErr, 0);
+       //      return 0;
+       //}
+
+       //sciErr = getVarType(_piKey, piAddressVarOne, &iType1);
+       //if(sciErr.iErr)
+       //{
+       //      printError(&sciErr, 0);
+       //      return 0;
+       //}
+
+       //if (iType1 == sci_matrix)
+       //{
+       //      sciErr = getVarDimension(_piKey, piAddressVarOne, &m1, &n1);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      if ( (m1 == n1) && (m1 == 0) )
+       //      {
+       //              sciErr = createMatrixOfDouble(_piKey, Rhs + 1, m1, n1, NULL);
+       //              if(sciErr.iErr)
+       //              {
+       //                      printError(&sciErr, 0);
+       //                      return 0;
+       //              }
+
+       //              LhsVar(1) = Rhs + 1;
+       //              C2F(putlhsvar)();
+       //      }
+       //      else
+       //      {
+       //              Scierror(999,_("%s: Wrong type for input argument #%d: String array expected.\n"), fname, 1);
+       //      }
+       //}
+       //else if (iType1 == sci_strings)
+       //{
+       //      sciErr = getVarDimension(_piKey, piAddressVarOne, &m1, &n1);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      lenStVarOne = (int*)MALLOC(sizeof(int) * (m1 * n1));
+       //      if (lenStVarOne == NULL)
+       //      {
+       //              Scierror(999,_("%s: Memory allocation error.\n"),fname);
+       //              return 0;
+       //      }
+
+       //      results = (wchar_t **)MALLOC(sizeof(wchar_t*) * (m1 * n1));
+
+       //      if (results == NULL)
+       //      {
+       //              if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+       //              freeArrayOfWideString(pStVarOne, m1 * n1);
+       //              Scierror(999,_("%s: Memory allocation error.\n"),fname);
+       //              return 0;
+       //      }
+
+       //      sciErr = getMatrixOfWideString(_piKey, piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      pStVarOne = (wchar_t**)MALLOC(sizeof(wchar_t*) * (m1 * n1));
+       //      if (pStVarOne == NULL)
+       //      {
+       //              if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+       //              Scierror(999,_("%s: Memory allocation error.\n"),fname);
+       //              return 0;
+       //      }
+
+       //      for( i = 0; i < m1 * n1; i++)
+       //      {
+       //              pStVarOne[i] = (wchar_t*)MALLOC(sizeof(wchar_t)*(lenStVarOne[i] + 1));
+       //              if (pStVarOne[i] == NULL)
+       //              {
+       //                      if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+       //                      freeArrayOfWideString(pStVarOne, m1 * n1);
+       //                      Scierror(999,_("%s: Memory allocation error.\n"),fname);
+       //                      return 0;
+       //              }
+       //      }
+
+       //      sciErr = getMatrixOfWideString(_piKey, piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      for( i = 0; i < m1 * n1; i++)
+       //      {
+       //              results[i] = pathconvertW(pStVarOne[i], flagtrail, flagexpand, PType);
+       //      }
+
+       //      sciErr = createMatrixOfWideString(_piKey, Rhs + 1, m1, n1, results);
+       //      if(sciErr.iErr)
+       //      {
+       //              printError(&sciErr, 0);
+       //              return 0;
+       //      }
+
+       //      LhsVar(1) = Rhs + 1;
+       //      C2F(putlhsvar)();
+
+       //      if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+       //      freeArrayOfWideString(results, m1 * n1);
+       //      freeArrayOfWideString(pStVarOne, m1 * n1);
+       //}
+       //else
+       //{
+       //      Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+       //      return 0;
+       //}
+       //return 0;
+}
+/*--------------------------------------------------------------------------*/
index 4e2a664..e184224 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <wchar.h>
 #include "BOOL.h"
+#include "dynlib_fileio.h"
 
 typedef enum { 
 WINDOWS_STYLE = 0,
@@ -23,9 +24,9 @@ UNIX_STYLE = 1,
 AUTO_STYLE = 2
 } PathConvertType;
 
-wchar_t *pathconvertW(wchar_t* wcpath, BOOL flagtrail, BOOL flagexpand, PathConvertType PType);
+FILEIO_IMPEXP wchar_t *pathconvertW(wchar_t* wcpath, BOOL flagtrail, BOOL flagexpand, PathConvertType PType);
 
-char *pathconvert(char* path, BOOL flagtrail, BOOL flagexpand, PathConvertType PType);
+FILEIO_IMPEXP char *pathconvert(char* path, BOOL flagtrail, BOOL flagexpand, PathConvertType PType);
 
 #endif /* PATHCONVERT_H__ */
 /*--------------------------------------------------------------------------*/ 
index 8ea49cd..970e854 100644 (file)
@@ -14,6 +14,7 @@ SYSTEM_ENV_CPP_SOURCES        = \
        src/cpp/setenvvar.cpp \
        src/cpp/sci_path.cpp \
        src/cpp/sci_home.cpp \
+       src/cpp/home.cpp \
        src/cpp/sci_tmpdir.cpp \
        src/cpp/sci_warning.cpp \
        src/cpp/sci_mode.cpp \
index 9a80a2c..92744d3 100644 (file)
@@ -86,7 +86,7 @@ LTLIBRARIES = $(pkglib_LTLIBRARIES)
 libscisystem_env_la_LIBADD =
 am__objects_1 = libscisystem_env_la-setenvvar.lo \
        libscisystem_env_la-sci_path.lo \
-       libscisystem_env_la-sci_home.lo \
+       libscisystem_env_la-sci_home.lo libscisystem_env_la-home.lo \
        libscisystem_env_la-sci_tmpdir.lo \
        libscisystem_env_la-sci_warning.lo \
        libscisystem_env_la-sci_mode.lo \
@@ -366,6 +366,7 @@ SYSTEM_ENV_CPP_SOURCES = \
        src/cpp/setenvvar.cpp \
        src/cpp/sci_path.cpp \
        src/cpp/sci_home.cpp \
+       src/cpp/home.cpp \
        src/cpp/sci_tmpdir.cpp \
        src/cpp/sci_warning.cpp \
        src/cpp/sci_mode.cpp \
@@ -460,6 +461,7 @@ distclean-compile:
        -rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisystem_env_la-configvariable.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisystem_env_la-home.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisystem_env_la-sci_home.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisystem_env_la-sci_mode.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscisystem_env_la-sci_path.Plo@am__quote@
@@ -509,6 +511,13 @@ libscisystem_env_la-sci_home.lo: src/cpp/sci_home.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) $(libscisystem_env_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscisystem_env_la-sci_home.lo `test -f 'src/cpp/sci_home.cpp' || echo '$(srcdir)/'`src/cpp/sci_home.cpp
 
+libscisystem_env_la-home.lo: src/cpp/home.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisystem_env_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscisystem_env_la-home.lo -MD -MP -MF $(DEPDIR)/libscisystem_env_la-home.Tpo -c -o libscisystem_env_la-home.lo `test -f 'src/cpp/home.cpp' || echo '$(srcdir)/'`src/cpp/home.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscisystem_env_la-home.Tpo $(DEPDIR)/libscisystem_env_la-home.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/home.cpp' object='libscisystem_env_la-home.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) $(libscisystem_env_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscisystem_env_la-home.lo `test -f 'src/cpp/home.cpp' || echo '$(srcdir)/'`src/cpp/home.cpp
+
 libscisystem_env_la-sci_tmpdir.lo: src/cpp/sci_tmpdir.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscisystem_env_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscisystem_env_la-sci_tmpdir.lo -MD -MP -MF $(DEPDIR)/libscisystem_env_la-sci_tmpdir.Tpo -c -o libscisystem_env_la-sci_tmpdir.lo `test -f 'src/cpp/sci_tmpdir.cpp' || echo '$(srcdir)/'`src/cpp/sci_tmpdir.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscisystem_env_la-sci_tmpdir.Tpo $(DEPDIR)/libscisystem_env_la-sci_tmpdir.Plo
index e1c9eb4..658b437 100644 (file)
@@ -39,7 +39,7 @@ public :
     static void setSCIPath(wstring& _SCIPath);
     static wstring getSCIPath();
 
-    //HOME
+    //SCIHOME
 private :
     static wstring m_SCIHOME;
 
@@ -103,6 +103,15 @@ private :
 public : 
     static void setWarningMode(bool _bWarningMode);
     static bool getWarningMode(void);
+
+    //HOME
+private :
+    static wstring m_HOME;
+
+public :
+    static void setHOME(wstring& _m_HOME);
+    static wstring getHOME();
+
 };
 
 #endif /* __CONFIGVARIABLE_HXX__ */
diff --git a/scilab/modules/system_env/includes/home.h b/scilab/modules/system_env/includes/home.h
new file mode 100644 (file)
index 0000000..fe7868d
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+*  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
+*
+*/
+
+#ifndef __HOME_H__
+#define __HOME_H__
+
+#include <wchar.h>
+#include "dynlib_system_env.h"
+#include "BOOL.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+EXTERN_SYSTEM_ENV wchar_t *getHOMEW(void);
+EXTERN_SYSTEM_ENV char *getHOME(void);
+
+EXTERN_SYSTEM_ENV void setHOMEW(const wchar_t* _sci_path);
+EXTERN_SYSTEM_ENV void setHOME(const char* _sci_path);
+
+EXTERN_SYSTEM_ENV wchar_t* computeHOMEW();
+EXTERN_SYSTEM_ENV char* computeHOME();
+
+EXTERN_SYSTEM_ENV wchar_t* getenvHOMEW(void);
+EXTERN_SYSTEM_ENV char* getenvHOME(void);
+
+EXTERN_SYSTEM_ENV void putenvHOMEW(const wchar_t* _sci_path);
+EXTERN_SYSTEM_ENV void putenvHOME(const char* _sci_path);
+
+EXTERN_SYSTEM_ENV void defineHOME();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ! __HOME_H__
index 3deb65d..518117f 100644 (file)
@@ -216,3 +216,22 @@ bool ConfigVariable::getWarningMode(void)
 ** \}
 */
 
+/*
+** HOME
+** \{
+*/
+
+wstring ConfigVariable::m_HOME;
+
+void ConfigVariable::setHOME(wstring& _HOME)
+{
+    m_HOME = _HOME;
+}
+
+wstring ConfigVariable::getHOME()
+{
+    return m_HOME;
+}
+/*
+** \}
+*/
diff --git a/scilab/modules/system_env/src/cpp/home.cpp b/scilab/modules/system_env/src/cpp/home.cpp
new file mode 100644 (file)
index 0000000..f9c4dcf
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+*  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 "home.h"
+
+#include "configvariable.hxx"
+
+#include "string.hxx"
+#include "context.hxx"
+#include "setenvvar.hxx"
+
+extern "C"
+{
+#include "os_strdup.h"
+#include "os_wcsdup.h"
+#include "charEncoding.h"
+#include "PATH_MAX.h"
+#include "machine.h"
+#include "version.h"
+#include "setenvc.h"
+#include "getenvc.h"
+}
+
+/*--------------------------------------------------------------------------*/
+wchar_t* getHOMEW(void)
+{
+    return os_wcsdup(ConfigVariable::getHOME().c_str());
+}
+/*--------------------------------------------------------------------------*/
+char* getHOME(void)
+{
+    return wide_string_to_UTF8(ConfigVariable::getHOME().c_str());
+}
+/*--------------------------------------------------------------------------*/
+void setHOME(const char* _home)
+{
+    wchar_t* pstTemp = to_wide_string(_home);
+    setHOMEW(pstTemp);
+    FREE(pstTemp);
+}
+/*--------------------------------------------------------------------------*/
+void setHOMEW(const wchar_t* _home)
+{
+    //add SCI value in context as variable
+    types::String *pS = new types::String(_home);
+    symbol::Context::getInstance()->put(L"home", *pS);
+
+    std::wstring home(_home);
+    ConfigVariable::setHOME(home);
+}
+
+/*--------------------------------------------------------------------------*/
+wchar_t* computeHOMEW(void)
+{
+    char* pstTemp = computeHOME();
+    wchar_t* pstReturn = to_wide_string(pstTemp);
+    FREE(pstTemp);
+    return pstReturn;
+}
+/*--------------------------------------------------------------------------*/
+char* computeHOME(void)
+{
+    char *pstHOME = getenvHOME();
+    if (pstHOME == NULL)
+    {
+        int ierr, iflag = 0;
+        int lbuf = PATH_MAX;
+        char *pstUserProfile = new char[PATH_MAX];
+        getenvc(&ierr, "USERPROFILE", pstUserProfile, &lbuf, &iflag);
+        if(ierr != 1)
+        {
+            return pstUserProfile;
+        }
+        else
+        {
+            /* if USERPROFILE is not defined , we use default profile */
+            getenvc(&ierr, "ALLUSERSPROFILE", pstUserProfile, &lbuf, &iflag);
+            if(ierr != 1)
+            {
+                return pstUserProfile;
+            }
+            else
+            {
+                return NULL;
+            }
+        }
+    }
+    return pstHOME;
+}
+/*--------------------------------------------------------------------------*/
+char* getenvHOME(void)
+{
+    int ierr, iflag = 0;
+    int lbuf = PATH_MAX;
+    char *Home = new char[PATH_MAX];
+
+    if(Home)
+    {
+        getenvc(&ierr, "HOME", Home, &lbuf, &iflag);
+
+        if(ierr == 1)
+        {
+            return NULL;
+        }
+    }
+    return Home;
+}
+/*--------------------------------------------------------------------------*/
+wchar_t* getenvHOMEW(void)
+{
+    char *Home = getenvHOME();
+    wchar_t* pstTemp = to_wide_string(Home);
+    delete[] Home;
+    return pstTemp;
+}
+/*--------------------------------------------------------------------------*/
+void putenvHOMEW(const wchar_t* _home)
+{
+    char* pstTemp = wide_string_to_UTF8(_home);
+    putenvHOME(pstTemp);
+    FREE(pstTemp);
+    return;
+}
+
+void putenvHOME(const char* _home)
+{
+    char *ShortPath = NULL;
+    char *CopyOfDefaultPath = NULL;
+
+    CopyOfDefaultPath = new char[strlen(_home) + 1];
+    if (CopyOfDefaultPath)
+    {
+        /* to be sure that it's unix 8.3 format */
+        /* c:/progra~1/scilab-5.0 */
+        bool bConvertOK = false;
+        ShortPath = getshortpathname(_home, &bConvertOK);
+        AntislashToSlash(ShortPath,CopyOfDefaultPath);
+        setenvc("HOME", ShortPath);
+        if(CopyOfDefaultPath)
+        {
+            delete[] CopyOfDefaultPath;
+            CopyOfDefaultPath = NULL;
+        }
+
+        if(ShortPath)
+        {
+            delete[] ShortPath;
+            ShortPath = NULL;
+        }
+    }
+    return;
+}
+
+/*--------------------------------------------------------------------------*/
+void defineHOME()
+{
+    wchar_t* home = computeHOMEW();
+    setHOMEW(home);
+    putenvHOMEW(home);
+    FREE(home);
+}
index 6ba9555..46639f8 100644 (file)
@@ -39,6 +39,7 @@
 #include "context.hxx"
 #include "configvariable.hxx"
 #include "sci_home.h"
+#include "home.h"
 #include "sci_path.h"
 #include "sci_tmpdir.h"
 
@@ -69,7 +70,7 @@ void SetScilabEnvironment(void)
     //create TMPDIR
     defineTMPDIR();
     //create home
-    //TODO: create home
+    defineHOME();
 }
 
 #ifdef _MSC_VER
index 672118a..100fb11 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\src\cpp\home.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\src\cpp\sci_home.cpp"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath=".\includes\home.h"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\includes\sci_home.h"
                                >
                        </File>