add createdir function 32/2532/2
Antoine ELIAS [Fri, 19 Nov 2010 14:27:42 +0000 (15:27 +0100)]
Change-Id: I362a6c01eb17cdbf926c78dab7ddffd93b3759e6

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/gw_fileio.c
scilab/modules/fileio/sci_gateway/c/sci_createdir.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_createdir.cpp [new file with mode: 0644]

index fa8d423..aedb532 100644 (file)
@@ -65,7 +65,6 @@ sci_gateway/c/sci_fullpath.c \
 sci_gateway/c/sci_pathsep.c \
 sci_gateway/c/sci_getlongpathname.c \
 sci_gateway/c/sci_removedir.c \
-sci_gateway/c/sci_createdir.c \
 sci_gateway/c/sci_chdir.c \
 sci_gateway/c/sci_pwd.c \
 sci_gateway/c/sci_mclearerr.c \
@@ -99,7 +98,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_isfile.cpp \
        sci_gateway/cpp/sci_deletefile.cpp \
        sci_gateway/cpp/sci_getshortpathname.cpp \
-       sci_gateway/cpp/sci_fileext.cpp
+       sci_gateway/cpp/sci_fileext.cpp \
+       sci_gateway/cpp/sci_createdir.cpp
 
 
 FILEIO_CPP_SOURCES = \
index c923402..5a65794 100644 (file)
@@ -161,8 +161,7 @@ am__objects_3 = libscifileio_la-gw_fileio.lo \
        libscifileio_la-sci_getdrives.lo \
        libscifileio_la-sci_fullpath.lo libscifileio_la-sci_pathsep.lo \
        libscifileio_la-sci_getlongpathname.lo \
-       libscifileio_la-sci_removedir.lo \
-       libscifileio_la-sci_createdir.lo libscifileio_la-sci_chdir.lo \
+       libscifileio_la-sci_removedir.lo libscifileio_la-sci_chdir.lo \
        libscifileio_la-sci_pwd.lo libscifileio_la-sci_mclearerr.lo \
        libscifileio_la-sci_merror.lo libscifileio_la-sci_mgetstr.lo \
        libscifileio_la-sci_moef.lo libscifileio_la-sci_mputstr.lo \
@@ -184,7 +183,8 @@ am__objects_4 = libscifileio_la-fileio_gw.lo \
        libscifileio_la-sci_fileinfo.lo libscifileio_la-sci_isfile.lo \
        libscifileio_la-sci_deletefile.lo \
        libscifileio_la-sci_getshortpathname.lo \
-       libscifileio_la-sci_fileext.lo
+       libscifileio_la-sci_fileext.lo \
+       libscifileio_la-sci_createdir.lo
 am_libscifileio_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
        $(am__objects_3) $(am__objects_4)
 libscifileio_la_OBJECTS = $(am_libscifileio_la_OBJECTS)
@@ -531,7 +531,6 @@ sci_gateway/c/sci_fullpath.c \
 sci_gateway/c/sci_pathsep.c \
 sci_gateway/c/sci_getlongpathname.c \
 sci_gateway/c/sci_removedir.c \
-sci_gateway/c/sci_createdir.c \
 sci_gateway/c/sci_chdir.c \
 sci_gateway/c/sci_pwd.c \
 sci_gateway/c/sci_mclearerr.c \
@@ -565,7 +564,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_isfile.cpp \
        sci_gateway/cpp/sci_deletefile.cpp \
        sci_gateway/cpp/sci_getshortpathname.cpp \
-       sci_gateway/cpp/sci_fileext.cpp
+       sci_gateway/cpp/sci_fileext.cpp \
+       sci_gateway/cpp/sci_createdir.cpp
 
 FILEIO_CPP_SOURCES = \
        src/cpp/expandPathVariable.cpp \
@@ -1305,13 +1305,6 @@ libscifileio_la-sci_removedir.lo: sci_gateway/c/sci_removedir.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_removedir.lo `test -f 'sci_gateway/c/sci_removedir.c' || echo '$(srcdir)/'`sci_gateway/c/sci_removedir.c
 
-libscifileio_la-sci_createdir.lo: sci_gateway/c/sci_createdir.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_createdir.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_createdir.Tpo -c -o libscifileio_la-sci_createdir.lo `test -f 'sci_gateway/c/sci_createdir.c' || echo '$(srcdir)/'`sci_gateway/c/sci_createdir.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_createdir.Tpo $(DEPDIR)/libscifileio_la-sci_createdir.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_createdir.c' object='libscifileio_la-sci_createdir.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_createdir.lo `test -f 'sci_gateway/c/sci_createdir.c' || echo '$(srcdir)/'`sci_gateway/c/sci_createdir.c
-
 libscifileio_la-sci_chdir.lo: sci_gateway/c/sci_chdir.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_chdir.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_chdir.Tpo -c -o libscifileio_la-sci_chdir.lo `test -f 'sci_gateway/c/sci_chdir.c' || echo '$(srcdir)/'`sci_gateway/c/sci_chdir.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_chdir.Tpo $(DEPDIR)/libscifileio_la-sci_chdir.Plo
@@ -1613,6 +1606,13 @@ libscifileio_la-sci_fileext.lo: sci_gateway/cpp/sci_fileext.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_fileext.lo `test -f 'sci_gateway/cpp/sci_fileext.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_fileext.cpp
 
+libscifileio_la-sci_createdir.lo: sci_gateway/cpp/sci_createdir.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_createdir.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_createdir.Tpo -c -o libscifileio_la-sci_createdir.lo `test -f 'sci_gateway/cpp/sci_createdir.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_createdir.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-sci_createdir.Tpo $(DEPDIR)/libscifileio_la-sci_createdir.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_createdir.cpp' object='libscifileio_la-sci_createdir.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_createdir.lo `test -f 'sci_gateway/cpp/sci_createdir.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_createdir.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index 6d7f5bc..4dcfc4c 100644 (file)
                                >
                        </File>
                        <File
-                               RelativePath=".\sci_gateway\c\sci_createdir.c"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\sci_gateway\c\sci_fprintfMat.c"
                                >
                        </File>
index c71b32b..7bf3f62 100644 (file)
@@ -53,5 +53,6 @@ CPP_GATEWAY_PROTOTYPE(sci_fileinfo);
 CPP_GATEWAY_PROTOTYPE(sci_deletefile);
 CPP_GATEWAY_PROTOTYPE(sci_getshortpathname);
 CPP_GATEWAY_PROTOTYPE(sci_fileext);
+CPP_GATEWAY_PROTOTYPE(sci_createdir);
 
 #endif /* !__FILEIO_GW_HXX__ */
index 8ee43cc..95241c2 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_createdir(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_removedir(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);
index ab5a2f3..2d04e39 100644 (file)
@@ -48,7 +48,7 @@ static gw_generic_table Tab[]={
        {NULL, ""}, //fileext
        {NULL, ""}, //isdir
        {sci_removedir,"removedir"},
-       {sci_createdir,"createdir"},
+       {NULL,""}, //createdir
        {NULL, ""}, // pwd
        {NULL, ""}, //chdir
        {NULL, ""}, //fileinfo
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_createdir.c b/scilab/modules/fileio/sci_gateway/c/sci_createdir.c
deleted file mode 100644 (file)
index 49daf5a..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA - 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 "MALLOC.h"
-#include "createdirectory.h"
-#include "isdir.h"
-#include "expandPathVariable.h"
-#include "sci_warning.h"
-#include "sciprint.h"
-#include "Scierror.h"
-#include "localization.h"
-#include "PATH_MAX.h"
-/*--------------------------------------------------------------------------*/
-int sci_createdir(char *fname,unsigned long l)
-{
-       CheckRhs(1,1);
-       CheckLhs(0,1);
-
-       if (GetType(1) == sci_strings)
-       {
-               BOOL bOK = FALSE;
-               int m1 = 0, n1 = 0, l1 = 0;
-               char *expandedpath = NULL;
-               int out_n = 0;
-
-               GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
-
-               expandedpath = expandPathVariable(cstk(l1));
-
-               if (!isdir(expandedpath))
-               {
-                       bOK = createdirectory(expandedpath);
-               }
-               else
-               {
-                       if (getWarningMode()) sciprint(_("%s: Warning: Directory '%s' already exists.\n"),fname,expandedpath);
-                       bOK = TRUE;
-               }
-
-               if (expandedpath)
-               {
-                       FREE(expandedpath);
-                       expandedpath = NULL;
-               }
-
-               m1 = 1; n1 = 1;
-               CreateVar(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &m1, &n1 ,&l1);
-               *istk(l1) = bOK;
-
-               LhsVar(1)=Rhs+1;
-               C2F(putlhsvar)();
-       }
-       else
-       {
-               Scierror(999,_("%s: Wrong type for input argument: A string expected.\n"), fname);
-       }
-       return 0;
-}
-/*--------------------------------------------------------------------------*/
index 2cad970..203ffc2 100644 (file)
@@ -42,5 +42,6 @@ bool FileioModule::Load()
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"deletefile", &sci_deletefile, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"getshortpathname", &sci_getshortpathname, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"fileext", &sci_fileext, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"createdir", &sci_createdir, MODULE_NAME));
     return true;
 }
index 2fd8e53..08e98e0 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\sci_createdir.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\sci_deletefile.cpp"
                                >
                        </File>
diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_createdir.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_createdir.cpp
new file mode 100644 (file)
index 0000000..3d35488
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007 - INRIA - 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 "funcmanager.hxx"
+#include "fileio_gw.hxx"
+
+extern "C"
+{
+#include <string.h>
+#include "MALLOC.h"
+#include "createdirectory.h"
+#include "isdir.h"
+#include "expandPathVariable.h"
+#include "sci_warning.h"
+#include "sciprint.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "PATH_MAX.h"
+}
+/*--------------------------------------------------------------------------*/
+Function::ReturnValue sci_createdir(typed_list &in, int _iRetCount, typed_list &out)
+{
+    if(in.size() != 1)
+    {
+        ScierrorW(77, _W("%ls: Wrong number of input argument(s): %d expected.\n"), L"createdir", 1);
+        return Function::Error;
+    }
+
+    if(in[0]->isString() == false || in[0]->getAsString()->size_get() != 1)
+    {
+        ScierrorW(999,_W("%ls: Wrong type for input argument #%d: A String expected.\n"), L"createdir", 1);
+        return Function::Error;
+    }
+
+    wchar_t* pwstPath = expandPathVariableW(in[0]->getAsString()->string_get(0));
+    int iRet = 0;
+    if(!isdirW(pwstPath))
+    {
+        iRet = createdirectoryW(pwstPath);
+    }
+    else
+    {
+        if(getWarningMode())
+        {
+            sciprintW(_W("%ls: Warning: Directory '%ls' already exists.\n"), L"createdir", pwstPath);
+        }
+        iRet = 1;
+    }
+
+    FREE(pwstPath);
+    Bool* pOut = new Bool(iRet);
+
+    out.push_back(pOut);
+    return Function::OK;
+       //CheckRhs(1,1);
+       //CheckLhs(0,1);
+
+       //if (GetType(1) == sci_strings)
+       //{
+       //      BOOL bOK = FALSE;
+       //      int m1 = 0, n1 = 0, l1 = 0;
+       //      char *expandedpath = NULL;
+       //      int out_n = 0;
+
+       //      GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
+
+       //      expandedpath = expandPathVariable(cstk(l1));
+
+       //      if (!isdir(expandedpath))
+       //      {
+       //              bOK = createdirectory(expandedpath);
+       //      }
+       //      else
+       //      {
+       //              if (getWarningMode()) sciprint(_("%s: Warning: Directory '%s' already exists.\n"),fname,expandedpath);
+       //              bOK = TRUE;
+       //      }
+
+       //      if (expandedpath)
+       //      {
+       //              FREE(expandedpath);
+       //              expandedpath = NULL;
+       //      }
+
+       //      m1 = 1; n1 = 1;
+       //      CreateVar(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &m1, &n1 ,&l1);
+       //      *istk(l1) = bOK;
+
+       //      LhsVar(1)=Rhs+1;
+       //      C2F(putlhsvar)();
+       //}
+       //else
+       //{
+       //      Scierror(999,_("%s: Wrong type for input argument: A string expected.\n"), fname);
+       //}
+       //return 0;
+}
+/*--------------------------------------------------------------------------*/