add deletefile 34/2334/8
antoine ELIAS [Thu, 21 Oct 2010 10:25:17 +0000 (12:25 +0200)]
Change-Id: If7cb901ba3277be5ef46e37193d1af4ef86963d8

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_deletefile.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_deletefile.cpp [new file with mode: 0644]

index 7fd81f0..cc183a0 100644 (file)
@@ -62,7 +62,6 @@ sci_gateway/c/sci_fscanfMat.c \
 sci_gateway/c/sci_maxfiles.c \
 sci_gateway/c/sci_getdrives.c \
 sci_gateway/c/sci_fullpath.c \
-sci_gateway/c/sci_deletefile.c \
 sci_gateway/c/sci_pathsep.c \
 sci_gateway/c/sci_getshortpathname.c \
 sci_gateway/c/sci_getlongpathname.c \
@@ -99,7 +98,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_findfiles.cpp \
        sci_gateway/cpp/sci_basename.cpp \
        sci_gateway/cpp/sci_fileinfo.cpp \
-       sci_gateway/cpp/sci_isfile.cpp
+       sci_gateway/cpp/sci_isfile.cpp \
+       sci_gateway/cpp/sci_deletefile.cpp
 
 
 FILEIO_CPP_SOURCES = \
index 2aa61ac..c79a8e0 100644 (file)
@@ -158,9 +158,7 @@ am__objects_3 = libscifileio_la-gw_fileio.lo \
        libscifileio_la-sci_fscanfMat.lo \
        libscifileio_la-sci_maxfiles.lo \
        libscifileio_la-sci_getdrives.lo \
-       libscifileio_la-sci_fullpath.lo \
-       libscifileio_la-sci_deletefile.lo \
-       libscifileio_la-sci_pathsep.lo \
+       libscifileio_la-sci_fullpath.lo libscifileio_la-sci_pathsep.lo \
        libscifileio_la-sci_getshortpathname.lo \
        libscifileio_la-sci_getlongpathname.lo \
        libscifileio_la-sci_fileext.lo \
@@ -184,7 +182,8 @@ am__objects_4 = libscifileio_la-fileio_gw.lo \
        libscifileio_la-sci_fileparts.lo \
        libscifileio_la-sci_findfiles.lo \
        libscifileio_la-sci_basename.lo \
-       libscifileio_la-sci_fileinfo.lo libscifileio_la-sci_isfile.lo
+       libscifileio_la-sci_fileinfo.lo libscifileio_la-sci_isfile.lo \
+       libscifileio_la-sci_deletefile.lo
 am_libscifileio_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
        $(am__objects_3) $(am__objects_4)
 libscifileio_la_OBJECTS = $(am_libscifileio_la_OBJECTS)
@@ -528,7 +527,6 @@ sci_gateway/c/sci_fscanfMat.c \
 sci_gateway/c/sci_maxfiles.c \
 sci_gateway/c/sci_getdrives.c \
 sci_gateway/c/sci_fullpath.c \
-sci_gateway/c/sci_deletefile.c \
 sci_gateway/c/sci_pathsep.c \
 sci_gateway/c/sci_getshortpathname.c \
 sci_gateway/c/sci_getlongpathname.c \
@@ -565,7 +563,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_findfiles.cpp \
        sci_gateway/cpp/sci_basename.cpp \
        sci_gateway/cpp/sci_fileinfo.cpp \
-       sci_gateway/cpp/sci_isfile.cpp
+       sci_gateway/cpp/sci_isfile.cpp \
+       sci_gateway/cpp/sci_deletefile.cpp
 
 FILEIO_CPP_SOURCES = \
        src/cpp/expandPathVariable.cpp \
@@ -1284,13 +1283,6 @@ libscifileio_la-sci_fullpath.lo: sci_gateway/c/sci_fullpath.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_fullpath.lo `test -f 'sci_gateway/c/sci_fullpath.c' || echo '$(srcdir)/'`sci_gateway/c/sci_fullpath.c
 
-libscifileio_la-sci_deletefile.lo: sci_gateway/c/sci_deletefile.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_deletefile.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_deletefile.Tpo -c -o libscifileio_la-sci_deletefile.lo `test -f 'sci_gateway/c/sci_deletefile.c' || echo '$(srcdir)/'`sci_gateway/c/sci_deletefile.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_deletefile.Tpo $(DEPDIR)/libscifileio_la-sci_deletefile.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_deletefile.c' object='libscifileio_la-sci_deletefile.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_deletefile.lo `test -f 'sci_gateway/c/sci_deletefile.c' || echo '$(srcdir)/'`sci_gateway/c/sci_deletefile.c
-
 libscifileio_la-sci_pathsep.lo: sci_gateway/c/sci_pathsep.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_pathsep.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_pathsep.Tpo -c -o libscifileio_la-sci_pathsep.lo `test -f 'sci_gateway/c/sci_pathsep.c' || echo '$(srcdir)/'`sci_gateway/c/sci_pathsep.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscifileio_la-sci_pathsep.Tpo $(DEPDIR)/libscifileio_la-sci_pathsep.Plo
@@ -1613,6 +1605,13 @@ libscifileio_la-sci_isfile.lo: sci_gateway/cpp/sci_isfile.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_isfile.lo `test -f 'sci_gateway/cpp/sci_isfile.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_isfile.cpp
 
+libscifileio_la-sci_deletefile.lo: sci_gateway/cpp/sci_deletefile.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_deletefile.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-sci_deletefile.Tpo -c -o libscifileio_la-sci_deletefile.lo `test -f 'sci_gateway/cpp/sci_deletefile.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_deletefile.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-sci_deletefile.Tpo $(DEPDIR)/libscifileio_la-sci_deletefile.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_deletefile.cpp' object='libscifileio_la-sci_deletefile.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_deletefile.lo `test -f 'sci_gateway/cpp/sci_deletefile.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_deletefile.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index c86a14b..ab46377 100644 (file)
                                >
                        </File>
                        <File
-                               RelativePath=".\sci_gateway\c\sci_deletefile.c"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\sci_gateway\c\sci_fileext.c"
                                >
                        </File>
index ac711f3..19ac617 100644 (file)
@@ -50,5 +50,6 @@ CPP_GATEWAY_PROTOTYPE(sci_findfiles);
 CPP_GATEWAY_PROTOTYPE(sci_basename);
 CPP_GATEWAY_PROTOTYPE(sci_isfile);
 CPP_GATEWAY_PROTOTYPE(sci_fileinfo);
+CPP_GATEWAY_PROTOTYPE(sci_deletefile);
 
 #endif /* !__FILEIO_GW_HXX__ */
index 6310d25..5cea466 100644 (file)
@@ -31,7 +31,6 @@ FILEIO_IMPEXP int sci_fscanf(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_maxfiles(char *fname,unsigned long fname_len);
 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_deletefile(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_pathsep(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_getlongpathname(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_getshortpathname(char *fname,unsigned long fname_len);
index 1045f88..9ec40c7 100644 (file)
@@ -40,7 +40,7 @@ static gw_generic_table Tab[]={
        {sci_maxfiles,"maxfiles"},
        {sci_getdrives,"getdrives"},
        {sci_fullpath,"fullpath"},
-       {sci_deletefile,"deletefile"},
+       {NULL, ""}, //deletefile
        {sci_pathsep,"pathsep"},
        {NULL, ""}, //filesep
        {sci_getlongpathname,"getlongpathname"},
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_deletefile.c b/scilab/modules/fileio/sci_gateway/c/sci_deletefile.c
deleted file mode 100644 (file)
index 7da6b1c..0000000
+++ /dev/null
@@ -1,56 +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 "gw_fileio.h"
-#include "stack-c.h"
-#include "MALLOC.h"
-#include "Scierror.h"
-#include "deleteafile.h"
-#include "localization.h"
-/*--------------------------------------------------------------------------*/
-int sci_deletefile(char *fname,unsigned long fname_len)
-{
-       CheckRhs(1,1);
-       CheckLhs(1,1);
-
-       if (GetType(1) == sci_strings)
-       {
-               int m1,n1,l1;
-               char *VarName=NULL;
-
-               GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
-               /* Bug 3089 */
-               VarName = cstk(l1);
-
-               n1=1;
-               if ( deleteafile(VarName) )
-               {
-                       CreateVar(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &n1,&n1,&l1);
-                       *istk(l1)=(int)(TRUE);
-               }
-               else
-               {
-                       CreateVar(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &n1,&n1,&l1);
-                       *istk(l1)=(int)(FALSE);
-               }
-
-               LhsVar(1)=Rhs+1;
-               C2F(putlhsvar)();
-       }
-       else
-       {
-               Scierror(999,_("%s: Wrong type for input argument: A string expected.\n"),fname);
-       }
-       return 0;
-}
-/*--------------------------------------------------------------------------*/
index 60c93a3..ab736d0 100644 (file)
@@ -39,5 +39,6 @@ bool FileioModule::Load()
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"basename", &sci_basename, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"isfile", &sci_isfile, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"fileinfo", &sci_fileinfo, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"deletefile", &sci_deletefile, MODULE_NAME));
     return true;
 }
index 2d059d9..6e08975 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\sci_deletefile.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\sci_fileparts.cpp"
                                >
                        </File>
diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_deletefile.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_deletefile.cpp
new file mode 100644 (file)
index 0000000..1382d92
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007 - INRIA - Allan CORNET
+ * Copyright (C) 2010 - INRIA - 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 "filemanager.hxx"
+#include "fileio_gw.hxx"
+
+extern "C"
+{
+#include "Scierror.h"
+#include "deleteafile.h"
+#include "localization.h"
+}
+/*--------------------------------------------------------------------------*/
+Function::ReturnValue sci_deletefile(typed_list &in, int _iRetCount, typed_list &out)
+{
+    if(in.size() != 1)
+    {
+        ScierrorW(999, _W("%ls: Wrong number of input arguments: %d expected.\n"), L"deletefile", 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"deletefile", 1);
+        return Function::Error;
+    }
+
+
+    Bool *pOut = NULL;
+    if(deleteafileW(in[0]->getAsString()->string_get(0)))
+    {
+        pOut = new Bool(1);
+    }
+    else
+    {
+        pOut = new Bool(0);
+    }
+
+    out.push_back(pOut);
+    return Function::OK;
+       //CheckRhs(1,1);
+       //CheckLhs(1,1);
+
+       //if (GetType(1) == sci_strings)
+       //{
+       //      int m1,n1,l1;
+       //      char *VarName=NULL;
+
+       //      GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
+       //      /* Bug 3089 */
+       //      VarName = cstk(l1);
+
+       //      n1=1;
+       //      if ( deleteafile(VarName) )
+       //      {
+       //              CreateVar(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &n1,&n1,&l1);
+       //              *istk(l1)=(int)(TRUE);
+       //      }
+       //      else
+       //      {
+       //              CreateVar(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &n1,&n1,&l1);
+       //              *istk(l1)=(int)(FALSE);
+       //      }
+
+       //      LhsVar(1)=Rhs+1;
+       //      C2F(putlhsvar)();
+       //}
+       //else
+       //{
+       //      Scierror(999,_("%s: Wrong type for input argument: A string expected.\n"),fname);
+       //}
+       //return 0;
+}
+/*--------------------------------------------------------------------------*/