file function added. 37/12437/7
Cedric Delamarre [Thu, 5 Sep 2013 14:13:32 +0000 (16:13 +0200)]
Change-Id: Ia2eb55ab9afe055a87b78b7def14c973477900a3

35 files changed:
scilab/modules/core/Makefile.am
scilab/modules/core/Makefile.in
scilab/modules/core/src/fortran/backspace_inter.f [new file with mode: 0644]
scilab/modules/core/src/fortran/clunit.f
scilab/modules/core/src/fortran/core_f.vfproj
scilab/modules/core/src/fortran/read_inter.f [new file with mode: 0644]
scilab/modules/core/src/fortran/rewind_inter.f [new file with mode: 0644]
scilab/modules/fileio/Makefile.am
scilab/modules/fileio/Makefile.in
scilab/modules/fileio/core_Import.def
scilab/modules/fileio/core_f_Import.def [new file with mode: 0644]
scilab/modules/fileio/fileio.vcxproj
scilab/modules/fileio/fileio.vcxproj.filters
scilab/modules/fileio/includes/filemanager.hxx
scilab/modules/fileio/sci_gateway/cpp/sci_mfprintf.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mfscanf.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mget.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mgetl.cpp
scilab/modules/fileio/src/cpp/addfile.cpp [moved from scilab/modules/fileio/src/c/addfile.c with 53% similarity]
scilab/modules/fileio/src/cpp/delfile.cpp [moved from scilab/modules/fileio/src/c/delfile.c with 53% similarity]
scilab/modules/fileio/src/cpp/filemanager.cpp
scilab/modules/fileio/src/cpp/getfiledesc.cpp [moved from scilab/modules/fileio/src/c/getfiledesc.c with 64% similarity]
scilab/modules/fileio/src/cpp/getfileinfo.cpp [moved from scilab/modules/fileio/src/c/getfileinfo.c with 56% similarity]
scilab/modules/fileio/src/cpp/getfiletype.cpp [moved from scilab/modules/fileio/src/c/getfiletype.c with 65% similarity]
scilab/modules/fileio/src/cpp/mclose.cpp
scilab/modules/fileio/src/cpp/mgetl.cpp
scilab/modules/fileio/src/cpp/mgetstr.cpp
scilab/modules/fileio/src/cpp/mputl.cpp
scilab/modules/fileio/src/cpp/mtell.cpp
scilab/modules/io/sci_gateway/cpp/sci_file.cpp
scilab/modules/io/src/cpp/core_f_Import.def [new file with mode: 0644]
scilab/modules/io/src/cpp/io_gw.vcxproj
scilab/modules/io/src/cpp/io_gw.vcxproj.filters
scilab/modules/types/includes/file.hxx
scilab/modules/types/src/cpp/file.cpp

index ffcfa51..face994 100644 (file)
@@ -122,7 +122,10 @@ src/fortran/itosci.f \
 src/fortran/stackr2d.f \
 src/fortran/stacki2d.f \
 src/fortran/stackc2i.f \
-src/fortran/isinstring.f
+src/fortran/isinstring.f \
+src/fortran/read_inter.f \
+src/fortran/rewind_inter.f \
+src/fortran/backspace_inter.f
 
 if USE_DYNAMIC_STACK
 CORE_FORTRAN_SOURCES += src/fortran/relocstack.f
index d141d79..eb7dd7b 100644 (file)
@@ -220,7 +220,8 @@ am__libscicore_algo_la_SOURCES_DIST = src/c/csignal.c src/c/cs2st.c \
        src/fortran/putid.f src/fortran/itosci.f \
        src/fortran/stackr2d.f src/fortran/stacki2d.f \
        src/fortran/stackc2i.f src/fortran/isinstring.f \
-       src/fortran/relocstack.f
+       src/fortran/read_inter.f src/fortran/rewind_inter.f \
+       src/fortran/backspace_inter.f src/fortran/relocstack.f
 @USE_DYNAMIC_STACK_TRUE@am__objects_1 =  \
 @USE_DYNAMIC_STACK_TRUE@       libscicore_algo_la-scimem64.lo
 am__objects_2 = libscicore_algo_la-csignal.lo \
@@ -284,6 +285,7 @@ am__objects_5 = clunit.lo getlin.lo allowptr.lo isany.lo setgetmode.lo \
        indxg.lo istrue.lo extlarg.lo lst2vars.lo basnms.lo ptrback.lo \
        getch.lo ftob.lo expsum.lo copyvar.lo putid.lo itosci.lo \
        stackr2d.lo stacki2d.lo stackc2i.lo isinstring.lo \
+       read_inter.lo rewind_inter.lo backspace_inter.lo \
        $(am__objects_4)
 am_libscicore_algo_la_OBJECTS = $(am__objects_2) $(am__objects_3) \
        $(am__objects_5)
@@ -742,7 +744,9 @@ CORE_FORTRAN_SOURCES = src/fortran/clunit.f src/fortran/getlin.f \
        src/fortran/expsum.f src/fortran/copyvar.f src/fortran/putid.f \
        src/fortran/itosci.f src/fortran/stackr2d.f \
        src/fortran/stacki2d.f src/fortran/stackc2i.f \
-       src/fortran/isinstring.f $(am__append_2)
+       src/fortran/isinstring.f src/fortran/read_inter.f \
+       src/fortran/rewind_inter.f src/fortran/backspace_inter.f \
+       $(am__append_2)
 GATEWAY_C_SOURCES = \
        sci_gateway/c/gw_core.c \
        sci_gateway/c/gw_user.c \
@@ -2030,6 +2034,15 @@ stackc2i.lo: src/fortran/stackc2i.f
 isinstring.lo: src/fortran/isinstring.f
        $(AM_V_F77)$(LIBTOOL) $(AM_V_lt) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o isinstring.lo `test -f 'src/fortran/isinstring.f' || echo '$(srcdir)/'`src/fortran/isinstring.f
 
+read_inter.lo: src/fortran/read_inter.f
+       $(AM_V_F77)$(LIBTOOL) $(AM_V_lt) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o read_inter.lo `test -f 'src/fortran/read_inter.f' || echo '$(srcdir)/'`src/fortran/read_inter.f
+
+rewind_inter.lo: src/fortran/rewind_inter.f
+       $(AM_V_F77)$(LIBTOOL) $(AM_V_lt) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o rewind_inter.lo `test -f 'src/fortran/rewind_inter.f' || echo '$(srcdir)/'`src/fortran/rewind_inter.f
+
+backspace_inter.lo: src/fortran/backspace_inter.f
+       $(AM_V_F77)$(LIBTOOL) $(AM_V_lt) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o backspace_inter.lo `test -f 'src/fortran/backspace_inter.f' || echo '$(srcdir)/'`src/fortran/backspace_inter.f
+
 relocstack.lo: src/fortran/relocstack.f
        $(AM_V_F77)$(LIBTOOL) $(AM_V_lt) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o relocstack.lo `test -f 'src/fortran/relocstack.f' || echo '$(srcdir)/'`src/fortran/relocstack.f
 
diff --git a/scilab/modules/core/src/fortran/backspace_inter.f b/scilab/modules/core/src/fortran/backspace_inter.f
new file mode 100644 (file)
index 0000000..e9c4cb9
--- /dev/null
@@ -0,0 +1,15 @@
+c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+c Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
+c
+c This file must be used under the terms of the CeCILL.
+c This source file is licensed as described in the file COPYING, which
+c you should have received as part of this distribution.  The terms
+c are also available at
+c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+      subroutine backspace_inter(lunit)
+c     interface for file gateway
+        integer lunit
+c
+        backspace(lunit)
+c
+      end
index 6555977..a2fe0be 100644 (file)
@@ -1,13 +1,13 @@
 c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 c Copyright (C) INRIA
-c 
+c
 c This file must be used under the terms of the CeCILL.
 c This source file is licensed as described in the file COPYING, which
 c you should have received as part of this distribution.  The terms
-c are also available at    
+c are also available at
 c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 
-      subroutine clunit( lunit, name, mode)
+      function clunit( lunit, name, mode)
 c ====================================================================
 c
 c     system dependent routine to allocate files
@@ -41,45 +41,31 @@ c           fortran : len
 c
 c ====================================================================
 c
-      include 'stack.h'
+c     input
+c
       integer       lunit,mode(*)
       character*(*) name
 c
+c     output
+c
+      integer       clunit
+c
 c      integer        nunit,unit(50)
 c      common /units/ nunit,unit
 c
-      integer       iacc,ifor,ista,k,rec
+      integer       iacc,ifor,ista,k,rec,err
       character*11  for,sta,acc
       character*800  nomfic
       double precision res
-c
-      if ( lunit.eq.rte) then
-c     attach units  rte   to terminal in
-         call addfile (lunit,1,0,1,001,char(0),ierr)
-         if(ierr.ne.0) then
-            call error(112)
-            return
-         endif
-         goto 100
-      elseif(lunit.eq.wte ) then
-c     attach units   wte  to terminal out
-         call addfile (lunit,1,0,1,000,char(0),ierr)
-         if(ierr.ne.0) then
-            call error(112)
-            return
-         endif
-         goto 100
-      endif
-
+      err = 0
 c
 c ----------
 c close file
 c ----------
 c
       if ( lunit.lt.0 ) then
 c     .  preserve permanent files
-         if (lunit.eq.-rte.or.lunit.eq.-wte) goto 100
+         if (lunit.eq.-5.or.lunit.eq.-6) goto 100
 c     .  close file and put it out of the table
          call getfiletype(-lunit,ltype,info)
          if(info.eq.0) then
@@ -143,7 +129,7 @@ c     .        unit is free
                   return
                endif
             elseif(info.eq.1) then
-c     .        unit is out of bounds
+c     .        cannot add file with negativ lunit
                call error(66)
                return
             else
@@ -159,13 +145,13 @@ c     .        unit is not free
             endif
          else
 c     .     file is defined by its name
-            call getfiledesc(lunit) 
+            call getfiledesc(lunit)
             if(lunit.lt.0) then
                err = 66
                return
             endif
 c     .     get full file name
-            call cluni0(name, nomfic, k)    
+            call cluni0(name, nomfic, k)
             if ( iacc.ne.0 ) then
                open( lunit, file=nomfic(1:k), form=for,
      1              access=acc , status=sta,recl=rec, err=30)
@@ -205,5 +191,7 @@ c --------------
 c end of program
 c --------------
 c
-  100 continue
+  100 clunit = err
+      return
+
       end
index f2db4b2..e2421c5 100644 (file)
@@ -70,6 +70,7 @@
                <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"/>
                <Filter Name="Source Files" Filter="f90;for;f;fpp;ftn;def;odl;idl">
                <File RelativePath="allowptr.f"/>
+               <File RelativePath=".\backspace_inter.f"/>
                <File RelativePath="basnms.f"/>
                <File RelativePath="bexec.f"/>
                <File RelativePath="btof.f"/>
                <File RelativePath="prompt.f"/>
                <File RelativePath="ptrback.f"/>
                <File RelativePath="putid.f"/>
+               <File RelativePath=".\read_inter.f"/>
                <File RelativePath="ref2val.f"/>
+               <File RelativePath=".\rewind_inter.f"/>
                <File RelativePath="savlod.f"/>
                <File RelativePath="setgetmode.f"/>
                <File RelativePath="setippty.f"/>
diff --git a/scilab/modules/core/src/fortran/read_inter.f b/scilab/modules/core/src/fortran/read_inter.f
new file mode 100644 (file)
index 0000000..09ae64a
--- /dev/null
@@ -0,0 +1,22 @@
+c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+c Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
+c
+c This file must be used under the terms of the CeCILL.
+c This source file is licensed as described in the file COPYING, which
+c you should have received as part of this distribution.  The terms
+c are also available at
+c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+      function read_inter(lunit,fmt)
+c     interface for "file" gateway
+        integer lunit, read_inter
+        character*(*) fmt
+c
+        read(lunit, fmt, err=20, end=30)
+c
+        read_inter = 0
+        return
+        read_inter = 2
+   20   return
+        read_inter = 1
+   30   return
+      end
diff --git a/scilab/modules/core/src/fortran/rewind_inter.f b/scilab/modules/core/src/fortran/rewind_inter.f
new file mode 100644 (file)
index 0000000..6b5197f
--- /dev/null
@@ -0,0 +1,15 @@
+c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+c Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
+c
+c This file must be used under the terms of the CeCILL.
+c This source file is licensed as described in the file COPYING, which
+c you should have received as part of this distribution.  The terms
+c are also available at
+c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+      subroutine rewind_inter(lunit)
+c     interface for "file" gateway
+        integer lunit
+c
+        rewind(lunit)
+c
+      end
index 7453fce..e611425 100644 (file)
@@ -10,12 +10,7 @@ FILEIO_C_SOURCES = \
     src/c/do_xxscanf.c \
     src/c/findfiles.c \
     src/c/Status2Mode.c \
-    src/c/addfile.c \
-    src/c/delfile.c \
     src/c/filesmanagement.c \
-    src/c/getfiledesc.c \
-    src/c/getfileinfo.c \
-    src/c/getfiletype.c \
     src/c/mgeti.c \
     src/c/mputi.c \
     src/c/readline.c \
@@ -112,7 +107,12 @@ FILEIO_CPP_SOURCES = \
        src/cpp/mseek.cpp \
        src/cpp/mtell.cpp \
        src/cpp/newest.cpp \
-       src/cpp/scilab_sscanf.cpp
+       src/cpp/scilab_sscanf.cpp \
+    src/cpp/addfile.cpp \
+    src/cpp/delfile.cpp \
+    src/cpp/getfiledesc.cpp \
+    src/cpp/getfileinfo.cpp \
+    src/cpp/getfiletype.cpp
 
 libscifileio_la_CPPFLAGS = \
     -I$(srcdir)/includes/ \
@@ -148,7 +148,7 @@ endif
 
 
 
-libscifileio_algo_la_SOURCES = $(FILEIO_C_SOURCES) $(FILEIO_CPP_SOURCES)
+libscifileio_algo_la_SOURCES = $(FILEIO_C_SOURCES) $(FILEIO_CPP_SOURCES) $(FILEIO_FORTRAN_SOURCES)
 libscifileio_la_SOURCES = $(GATEWAY_C_SOURCES) $(GATEWAY_CPP_SOURCES)
 libscifileio_algo_la_CPPFLAGS = $(libscifileio_la_CPPFLAGS)
 libscifileio_algo_la_LDFLAGS = $(CURL_LIBS)
index 00345cd..abc8174 100644 (file)
@@ -170,12 +170,7 @@ am__objects_1 = libscifileio_algo_la-FileExist.lo \
        libscifileio_algo_la-do_xxscanf.lo \
        libscifileio_algo_la-findfiles.lo \
        libscifileio_algo_la-Status2Mode.lo \
-       libscifileio_algo_la-addfile.lo \
-       libscifileio_algo_la-delfile.lo \
        libscifileio_algo_la-filesmanagement.lo \
-       libscifileio_algo_la-getfiledesc.lo \
-       libscifileio_algo_la-getfileinfo.lo \
-       libscifileio_algo_la-getfiletype.lo \
        libscifileio_algo_la-mgeti.lo libscifileio_algo_la-mputi.lo \
        libscifileio_algo_la-readline.lo \
        libscifileio_algo_la-getdrives.lo \
@@ -212,7 +207,12 @@ am__objects_2 = libscifileio_algo_la-expandPathVariable.lo \
        libscifileio_algo_la-filemanager.lo \
        libscifileio_algo_la-mseek.lo libscifileio_algo_la-mtell.lo \
        libscifileio_algo_la-newest.lo \
-       libscifileio_algo_la-scilab_sscanf.lo
+       libscifileio_algo_la-scilab_sscanf.lo \
+       libscifileio_algo_la-addfile.lo \
+       libscifileio_algo_la-delfile.lo \
+       libscifileio_algo_la-getfiledesc.lo \
+       libscifileio_algo_la-getfileinfo.lo \
+       libscifileio_algo_la-getfiletype.lo
 am_libscifileio_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libscifileio_algo_la_OBJECTS = $(am_libscifileio_algo_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -620,12 +620,7 @@ FILEIO_C_SOURCES = \
     src/c/do_xxscanf.c \
     src/c/findfiles.c \
     src/c/Status2Mode.c \
-    src/c/addfile.c \
-    src/c/delfile.c \
     src/c/filesmanagement.c \
-    src/c/getfiledesc.c \
-    src/c/getfileinfo.c \
-    src/c/getfiletype.c \
     src/c/mgeti.c \
     src/c/mputi.c \
     src/c/readline.c \
@@ -722,7 +717,12 @@ FILEIO_CPP_SOURCES = \
        src/cpp/mseek.cpp \
        src/cpp/mtell.cpp \
        src/cpp/newest.cpp \
-       src/cpp/scilab_sscanf.cpp
+       src/cpp/scilab_sscanf.cpp \
+    src/cpp/addfile.cpp \
+    src/cpp/delfile.cpp \
+    src/cpp/getfiledesc.cpp \
+    src/cpp/getfileinfo.cpp \
+    src/cpp/getfiletype.cpp
 
 libscifileio_la_CPPFLAGS = \
     -I$(srcdir)/includes/ \
@@ -751,7 +751,7 @@ libscifileio_la_CPPFLAGS = \
 @MAINTAINER_MODE_TRUE@pkglib_LTLIBRARIES = libscifileio.la
 @MAINTAINER_MODE_FALSE@noinst_LTLIBRARIES = libscifileio-algo.la libscifileio.la
 @MAINTAINER_MODE_TRUE@noinst_LTLIBRARIES = libscifileio-algo.la
-libscifileio_algo_la_SOURCES = $(FILEIO_C_SOURCES) $(FILEIO_CPP_SOURCES)
+libscifileio_algo_la_SOURCES = $(FILEIO_C_SOURCES) $(FILEIO_CPP_SOURCES) $(FILEIO_FORTRAN_SOURCES)
 libscifileio_la_SOURCES = $(GATEWAY_C_SOURCES) $(GATEWAY_CPP_SOURCES)
 libscifileio_algo_la_CPPFLAGS = $(libscifileio_la_CPPFLAGS)
 libscifileio_algo_la_LDFLAGS = $(CURL_LIBS)
@@ -1109,20 +1109,6 @@ libscifileio_algo_la-Status2Mode.lo: src/c/Status2Mode.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libscifileio_algo_la-Status2Mode.lo `test -f 'src/c/Status2Mode.c' || echo '$(srcdir)/'`src/c/Status2Mode.c
 
-libscifileio_algo_la-addfile.lo: src/c/addfile.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libscifileio_algo_la-addfile.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-addfile.Tpo -c -o libscifileio_algo_la-addfile.lo `test -f 'src/c/addfile.c' || echo '$(srcdir)/'`src/c/addfile.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-addfile.Tpo $(DEPDIR)/libscifileio_algo_la-addfile.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/addfile.c' object='libscifileio_algo_la-addfile.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libscifileio_algo_la-addfile.lo `test -f 'src/c/addfile.c' || echo '$(srcdir)/'`src/c/addfile.c
-
-libscifileio_algo_la-delfile.lo: src/c/delfile.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libscifileio_algo_la-delfile.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-delfile.Tpo -c -o libscifileio_algo_la-delfile.lo `test -f 'src/c/delfile.c' || echo '$(srcdir)/'`src/c/delfile.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-delfile.Tpo $(DEPDIR)/libscifileio_algo_la-delfile.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/delfile.c' object='libscifileio_algo_la-delfile.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libscifileio_algo_la-delfile.lo `test -f 'src/c/delfile.c' || echo '$(srcdir)/'`src/c/delfile.c
-
 libscifileio_algo_la-filesmanagement.lo: src/c/filesmanagement.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libscifileio_algo_la-filesmanagement.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-filesmanagement.Tpo -c -o libscifileio_algo_la-filesmanagement.lo `test -f 'src/c/filesmanagement.c' || echo '$(srcdir)/'`src/c/filesmanagement.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-filesmanagement.Tpo $(DEPDIR)/libscifileio_algo_la-filesmanagement.Plo
@@ -1130,27 +1116,6 @@ libscifileio_algo_la-filesmanagement.lo: src/c/filesmanagement.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libscifileio_algo_la-filesmanagement.lo `test -f 'src/c/filesmanagement.c' || echo '$(srcdir)/'`src/c/filesmanagement.c
 
-libscifileio_algo_la-getfiledesc.lo: src/c/getfiledesc.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libscifileio_algo_la-getfiledesc.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-getfiledesc.Tpo -c -o libscifileio_algo_la-getfiledesc.lo `test -f 'src/c/getfiledesc.c' || echo '$(srcdir)/'`src/c/getfiledesc.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-getfiledesc.Tpo $(DEPDIR)/libscifileio_algo_la-getfiledesc.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/getfiledesc.c' object='libscifileio_algo_la-getfiledesc.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libscifileio_algo_la-getfiledesc.lo `test -f 'src/c/getfiledesc.c' || echo '$(srcdir)/'`src/c/getfiledesc.c
-
-libscifileio_algo_la-getfileinfo.lo: src/c/getfileinfo.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libscifileio_algo_la-getfileinfo.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-getfileinfo.Tpo -c -o libscifileio_algo_la-getfileinfo.lo `test -f 'src/c/getfileinfo.c' || echo '$(srcdir)/'`src/c/getfileinfo.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-getfileinfo.Tpo $(DEPDIR)/libscifileio_algo_la-getfileinfo.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/getfileinfo.c' object='libscifileio_algo_la-getfileinfo.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libscifileio_algo_la-getfileinfo.lo `test -f 'src/c/getfileinfo.c' || echo '$(srcdir)/'`src/c/getfileinfo.c
-
-libscifileio_algo_la-getfiletype.lo: src/c/getfiletype.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libscifileio_algo_la-getfiletype.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-getfiletype.Tpo -c -o libscifileio_algo_la-getfiletype.lo `test -f 'src/c/getfiletype.c' || echo '$(srcdir)/'`src/c/getfiletype.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-getfiletype.Tpo $(DEPDIR)/libscifileio_algo_la-getfiletype.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/getfiletype.c' object='libscifileio_algo_la-getfiletype.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libscifileio_algo_la-getfiletype.lo `test -f 'src/c/getfiletype.c' || echo '$(srcdir)/'`src/c/getfiletype.c
-
 libscifileio_algo_la-mgeti.lo: src/c/mgeti.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libscifileio_algo_la-mgeti.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-mgeti.Tpo -c -o libscifileio_algo_la-mgeti.lo `test -f 'src/c/mgeti.c' || echo '$(srcdir)/'`src/c/mgeti.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-mgeti.Tpo $(DEPDIR)/libscifileio_algo_la-mgeti.Plo
@@ -1543,6 +1508,41 @@ libscifileio_algo_la-scilab_sscanf.lo: src/cpp/scilab_sscanf.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_algo_la-scilab_sscanf.lo `test -f 'src/cpp/scilab_sscanf.cpp' || echo '$(srcdir)/'`src/cpp/scilab_sscanf.cpp
 
+libscifileio_algo_la-addfile.lo: src/cpp/addfile.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_algo_la-addfile.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-addfile.Tpo -c -o libscifileio_algo_la-addfile.lo `test -f 'src/cpp/addfile.cpp' || echo '$(srcdir)/'`src/cpp/addfile.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-addfile.Tpo $(DEPDIR)/libscifileio_algo_la-addfile.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/addfile.cpp' object='libscifileio_algo_la-addfile.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_algo_la-addfile.lo `test -f 'src/cpp/addfile.cpp' || echo '$(srcdir)/'`src/cpp/addfile.cpp
+
+libscifileio_algo_la-delfile.lo: src/cpp/delfile.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_algo_la-delfile.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-delfile.Tpo -c -o libscifileio_algo_la-delfile.lo `test -f 'src/cpp/delfile.cpp' || echo '$(srcdir)/'`src/cpp/delfile.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-delfile.Tpo $(DEPDIR)/libscifileio_algo_la-delfile.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/delfile.cpp' object='libscifileio_algo_la-delfile.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_algo_la-delfile.lo `test -f 'src/cpp/delfile.cpp' || echo '$(srcdir)/'`src/cpp/delfile.cpp
+
+libscifileio_algo_la-getfiledesc.lo: src/cpp/getfiledesc.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_algo_la-getfiledesc.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-getfiledesc.Tpo -c -o libscifileio_algo_la-getfiledesc.lo `test -f 'src/cpp/getfiledesc.cpp' || echo '$(srcdir)/'`src/cpp/getfiledesc.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-getfiledesc.Tpo $(DEPDIR)/libscifileio_algo_la-getfiledesc.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/getfiledesc.cpp' object='libscifileio_algo_la-getfiledesc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_algo_la-getfiledesc.lo `test -f 'src/cpp/getfiledesc.cpp' || echo '$(srcdir)/'`src/cpp/getfiledesc.cpp
+
+libscifileio_algo_la-getfileinfo.lo: src/cpp/getfileinfo.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_algo_la-getfileinfo.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-getfileinfo.Tpo -c -o libscifileio_algo_la-getfileinfo.lo `test -f 'src/cpp/getfileinfo.cpp' || echo '$(srcdir)/'`src/cpp/getfileinfo.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-getfileinfo.Tpo $(DEPDIR)/libscifileio_algo_la-getfileinfo.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/getfileinfo.cpp' object='libscifileio_algo_la-getfileinfo.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_algo_la-getfileinfo.lo `test -f 'src/cpp/getfileinfo.cpp' || echo '$(srcdir)/'`src/cpp/getfileinfo.cpp
+
+libscifileio_algo_la-getfiletype.lo: src/cpp/getfiletype.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_algo_la-getfiletype.lo -MD -MP -MF $(DEPDIR)/libscifileio_algo_la-getfiletype.Tpo -c -o libscifileio_algo_la-getfiletype.lo `test -f 'src/cpp/getfiletype.cpp' || echo '$(srcdir)/'`src/cpp/getfiletype.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_algo_la-getfiletype.Tpo $(DEPDIR)/libscifileio_algo_la-getfiletype.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/getfiletype.cpp' object='libscifileio_algo_la-getfiletype.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_algo_la-getfiletype.lo `test -f 'src/cpp/getfiletype.cpp' || echo '$(srcdir)/'`src/cpp/getfiletype.cpp
+
 libscifileio_la-fileio_gw.lo: sci_gateway/cpp/fileio_gw.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_la-fileio_gw.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-fileio_gw.Tpo -c -o libscifileio_la-fileio_gw.lo `test -f 'sci_gateway/cpp/fileio_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/fileio_gw.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscifileio_la-fileio_gw.Tpo $(DEPDIR)/libscifileio_la-fileio_gw.Plo
index a3f1fe3..7b4c6b2 100644 (file)
@@ -29,4 +29,4 @@ getOSRelease
 getOSFullName
 MyHeapAlloc
 MyHeapFree
-MyHeapRealloc
+MyHeapRealloc
\ No newline at end of file
diff --git a/scilab/modules/fileio/core_f_Import.def b/scilab/modules/fileio/core_f_Import.def
new file mode 100644 (file)
index 0000000..e9653c4
--- /dev/null
@@ -0,0 +1,11 @@
+       LIBRARY    core_f.dll
+
+
+EXPORTS
+;
+;core
+;
+clunit_
+read_inter_
+rewind_inter_
+backspace_inter_
index 8310fdf..4f293a1 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
@@ -123,10 +123,10 @@ lib /DEF:"$(ProjectDir)Scilab_windows_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(
 lib /DEF:"$(ProjectDir)Localization_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)scilocalization.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)Console_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)sciconsole.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)system_env.lib" 1&gt;NUL 2&gt;NUL
-</Command>
+lib /DEF:"$(ProjectDir)core_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core_f.lib" 1&gt;NUL 2&gt;NUL</Command>
     </PreLinkEvent>
     <Link>
-      <AdditionalDependencies>core.lib;scilocalization.lib;sciconsole.lib;system_env.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>core_f.lib;core.lib;scilocalization.lib;sciconsole.lib;system_env.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Windows</SubSystem>
@@ -209,11 +209,15 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Plat
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="src\cpp\addfile.cpp" />
+    <ClCompile Include="src\cpp\delfile.cpp" />
+    <ClCompile Include="src\cpp\getfiledesc.cpp" />
+    <ClCompile Include="src\cpp\getfileinfo.cpp" />
+    <ClCompile Include="src\cpp\getfiletype.cpp" />
     <ClCompile Include="src\cpp\scilab_sscanf.cpp" />
     <ClCompile Include="sci_gateway\c\sci_getURL.c" />
     <ClCompile Include="sci_gateway\c\sci_splitURL.c" />
     <ClCompile Include="sci_gateway\c\sci_tempname.c" />
-    <ClCompile Include="src\c\addfile.c" />
     <ClCompile Include="src\c\basename.c" />
     <ClCompile Include="src\c\cluni0.c" />
     <ClCompile Include="src\c\convert_tools.c" />
@@ -221,7 +225,6 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Plat
     <ClCompile Include="src\c\createdirectory.c" />
     <ClCompile Include="src\c\createtempfilename.c" />
     <ClCompile Include="src\c\deleteafile.c" />
-    <ClCompile Include="src\c\delfile.c" />
     <ClCompile Include="src\c\DllmainFileio.c" />
     <ClCompile Include="src\c\dlManager.c" />
     <ClCompile Include="src\c\do_xxscanf.c" />
@@ -236,9 +239,6 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Plat
     <ClCompile Include="src\c\fscanfMat.c" />
     <ClCompile Include="src\c\fullpath.c" />
     <ClCompile Include="src\c\getdrives.c" />
-    <ClCompile Include="src\c\getfiledesc.c" />
-    <ClCompile Include="src\c\getfileinfo.c" />
-    <ClCompile Include="src\c\getfiletype.c" />
     <ClCompile Include="src\c\getFullFilename.c" />
     <ClCompile Include="src\c\getlongpathname.c" />
     <ClCompile Include="src\c\getrelativefilename.c" />
@@ -273,6 +273,7 @@ lib /DEF:"$(ProjectDir)System_env_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Plat
     <ResourceCompile Include="src\c\fileio.rc" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="core_f_Import.def" />
     <None Include="core_Import.def" />
     <None Include="locales\fileio.pot" />
     <None Include="Localization_Import.def" />
index 84e0987..365cd9a 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
     <Filter Include="Source Files">
@@ -24,9 +24,6 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="src\c\addfile.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="src\c\basename.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -42,9 +39,6 @@
     <ClCompile Include="src\c\deleteafile.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="src\c\delfile.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="src\c\DllmainFileio.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="src\c\getdrives.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="src\c\getfiledesc.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="src\c\getfileinfo.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="src\c\getfiletype.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="src\c\getFullFilename.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="src\c\convert_tools.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\addfile.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\delfile.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\getfiledesc.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\getfileinfo.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\cpp\getfiletype.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\mgetl.h">
     <None Include="core_Import.def">
       <Filter>Libraries Dependencies\Imports</Filter>
     </None>
+    <None Include="core_f_Import.def">
+      <Filter>Libraries Dependencies\Imports</Filter>
+    </None>
   </ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
index c2369c4..dfb479e 100644 (file)
@@ -33,6 +33,7 @@ public :
     static File*                getFile(int _iID);
     static int                  getCurrentFile();
     static int                  addFile(File* _file);
+    static int                  getFirstFreeFileID();
     static void                 deleteFile(int _iID);
     static int                  getOpenedCount();
     static wchar_t**            getTypesAsString();
index 3030d1c..28bbfc3 100644 (file)
@@ -46,7 +46,7 @@ Function::ReturnValue sci_mfprintf(types::typed_list &in, int _iRetCount, types:
     unsigned int iNumberPercent     = 0;
     unsigned int iNumberCols        = 0;
     int nbrOfLines                  = 0;
-    double dfileMode                = 0;
+    int ifileMode                   = 0;
     wchar_t* wcsInput               = NULL;
     wchar_t** wcsStringToWrite      = NULL;
     ArgumentPosition* pArgs         = NULL;
@@ -121,14 +121,21 @@ Function::ReturnValue sci_mfprintf(types::typed_list &in, int _iRetCount, types:
             return types::Function::Error;
         default:
             isSTD = FALSE;
-            dfileMode = FileManager::getFile(iFile)->getFileModeAsDouble();
+            types::File* pFile = FileManager::getFile(iFile);
+            // file opened with fortran open function
+            if (pFile->getFileType() == 1)
+            {
+                Scierror(999, _("%s: Wrong file descriptor: %d.\n"), "mfprintf", iFile);
+                return types::Function::Error;
+            }
+            ifileMode = pFile->getFileModeAsInt();
             break;
     }
 
     /* checks file mode */
     /* bug 3898 */
     /* read only attrib 1xx*/
-    if ((dfileMode >= 100) && (dfileMode < 200) && !isSTD)
+    if ((ifileMode >= 100) && (ifileMode < 200) && !isSTD)
     {
         Scierror(999, _("%s: Wrong file mode: READ only.\n"), "mfprintf");
         return types::Function::Error;
index bef0755..7170454 100644 (file)
@@ -83,12 +83,8 @@ types::Function::ReturnValue sci_mfscanf(types::typed_list &in, int _iRetCount,
     iFile = static_cast<int>(in[size - 2]->getAs<types::Double>()->get(0));
     switch (iFile)
     {
-        case 0:
-            // stderr
-            Scierror(999, _("%s: Wrong file descriptor: %d.\n"), "mfscanf", iFile);
-            return types::Function::Error;
-        case 6:
-            // stdout
+        case 0: // stderr
+        case 6: // stdout
             Scierror(999, _("%s: Wrong file descriptor: %d.\n"), "mfscanf", iFile);
             return types::Function::Error;
         default :
index 7b2c56d..83082b1 100644 (file)
@@ -83,6 +83,15 @@ Function::ReturnValue sci_mget(typed_list &in, int _iRetCount, typed_list &out)
             return types::Function::Error;
     }
 
+    types::File* pFile = FileManager::getFile(iFile);
+    // file opened with fortran open function
+    if (pFile->getFileType() == 1)
+    {
+        Scierror(999, _("%s: Wrong file descriptor: %d.\n"), "mget", iFile);
+        return types::Function::Error;
+    }
+
+
     C2F(mget)(&iFile, pData, &iSize, pstType, &iErr);
 
     if (iErr > 0)
index a7ed3fd..ec99f6b 100644 (file)
@@ -114,6 +114,14 @@ Function::ReturnValue sci_mgetl(typed_list &in, int _iRetCount, typed_list &out)
             return types::Function::Error;
         default :
         {
+            types::File* pFile = FileManager::getFile(iFileID);
+            // file opened with fortran open function
+            if (pFile->getFileType() == 1)
+            {
+                Scierror(999, _("%s: Wrong file descriptor: %d.\n"), "mgetl", iFileID);
+                return types::Function::Error;
+            }
+
             wcReadedStrings = mgetl(iFileID, iLinesExcepted, &iLinesRead, &iErr);
 
             switch (iErr)
similarity index 53%
rename from scilab/modules/fileio/src/c/addfile.c
rename to scilab/modules/fileio/src/cpp/addfile.cpp
index e502635..0b0b8b8 100644 (file)
@@ -1,53 +1,65 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA
- * ...
+ * Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
  *
  * 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.1-en.txt
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 /*--------------------------------------------------------------------------*/
+#include "filemanager.hxx"
+#include "file.hxx"
+
+extern "C"
+{
 #include "addfile.h"
 #include "filesmanagement.h"
+#include "charEncoding.h"
+#include "MALLOC.h"
+}
+
 /*--------------------------------------------------------------------------*/
 void C2F(addfile)(int *fd, FILE *fa, int *swap2, int *type, int *mode, char *filename, int *ierr)
 {
-    printf("Call of old addfile\n");
-    if (SetFileNameOpenedInScilab(*fd, filename) == FALSE )
-    {
-        *ierr = 1;
-        return;
-    }
+    wchar_t* wcsFilename = to_wide_string(filename);
+    types::File* pFile = new types::File();
+
+    pFile->setFilename(std::wstring(wcsFilename));
+
     if (*type == 2)
     {
-        SetFileOpenedInScilab(*fd, fa);
+        pFile->setFileDesc(fa);
+        pFile->setFileModeAsInt(*mode);
     }
     else if (*type == -1)
     {
-        SetFileOpenedInScilab(*fd, stdin);
+        pFile->setFileDesc(stdin);
     }
     else if (*type == -2)
     {
-        SetFileOpenedInScilab(*fd, stdout);
+        pFile->setFileDesc(stdout);
     }
     else if (*type == -3)
     {
-        SetFileOpenedInScilab(*fd, stderr);
+        pFile->setFileDesc(stderr);
     }
     else
     {
-        SetFileOpenedInScilab(*fd, (FILE *) 0);
+        pFile->setFileDesc((FILE*)0);
+        pFile->setFileFortranMode(*mode);
     }
 
-    SetSwapStatus(*fd, *swap2);
-    SetFileTypeOpenedInScilab(*fd, *type);
-    SetFileModeOpenedInScilab(*fd, *mode);
+    pFile->setFileSwap(*swap2);
+    pFile->setFileType(*type);
+
+    FileManager::addFile(pFile);
 
     *ierr = 0;
+
+    FREE(wcsFilename);
 }
 /*--------------------------------------------------------------------------*/
 
similarity index 53%
rename from scilab/modules/fileio/src/c/delfile.c
rename to scilab/modules/fileio/src/cpp/delfile.cpp
index 0fb5498..7826bc9 100644 (file)
@@ -1,32 +1,26 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA
- * ...
+ * Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
  *
  * 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.1-en.txt
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 /*--------------------------------------------------------------------------*/
-/* Scilab */
-/* INRIA 2007 */
-/*--------------------------------------------------------------------------*/
-#include <stdio.h>
+#include "filemanager.hxx"
+extern "C"
+{
 #include "delfile.h"
-#include "filesmanagement.h"
+}
 /*--------------------------------------------------------------------------*/
 void C2F(delfile)(int *fd)
 {
-    if (*fd >= 0 && *fd < GetMaximumFileOpenedInScilab() )
+    if (*fd >= 0 && *fd < FileManager::getFileMaxID())
     {
-        SetFileOpenedInScilab(*fd, (FILE*) NULL);
-        SetSwapStatus(*fd, 0);
-        SetFileTypeOpenedInScilab(*fd, 0);
-        SetFileModeOpenedInScilab(*fd, 0);
-        FreeFileNameOpenedInScilab(*fd);
+        FileManager::deleteFile(*fd);
     }
 }
 /*--------------------------------------------------------------------------*/
index cc6089b..dbba697 100644 (file)
@@ -93,6 +93,25 @@ int FileManager::addFile(types::File* _file)
     return iNewId;
 }
 
+int FileManager::getFirstFreeFileID()
+{
+    //find first free space
+    for (int i = 0 ; i < m_fileList.size() ; i++)
+    {
+        if (m_fileList[i] == NULL)
+        {
+            m_iCurrentFile = i;
+            return i;
+        }
+    }
+
+    //no free space, add at the end
+    m_fileList.push_back(NULL);
+    int iNewId = static_cast<int>(m_fileList.size());
+    m_iCurrentFile = iNewId;
+    return iNewId;
+}
+
 void FileManager::deleteFile(int _iID)
 {
     if (_iID <= m_fileList.size())
@@ -193,7 +212,7 @@ double* FileManager::getModes()
     {
         if (m_fileList[i] != NULL)
         {
-            pdblModes[iFileIndex++] = m_fileList[i]->getFileModeAsDouble();
+            pdblModes[iFileIndex++] = (double)(m_fileList[i]->getFileModeAsInt());
         }
     }
 
similarity index 64%
rename from scilab/modules/fileio/src/c/getfiledesc.c
rename to scilab/modules/fileio/src/cpp/getfiledesc.cpp
index fa21b82..ed88e45 100644 (file)
@@ -1,30 +1,23 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA
- * ...
+ * Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
  *
  * 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.1-en.txt
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 /*--------------------------------------------------------------------------*/
+#include "filemanager.hxx"
+extern "C"
+{
 #include "getfiledesc.h"
-#include "filesmanagement.h"
+}
 /*--------------------------------------------------------------------------*/
 void C2F(getfiledesc)(int *fd)
 {
-    int i ;
-    for ( i = 1 ; i < GetMaximumFileOpenedInScilab() ; i++)
-    {
-        if ( GetFileTypeOpenedInScilab(i) == 0 )
-        {
-            *fd = i;
-            return ;
-        }
-    }
-    *fd = -1;
+    *fd = FileManager::getFirstFreeFileID();
 }
 /*--------------------------------------------------------------------------*/
similarity index 56%
rename from scilab/modules/fileio/src/c/getfileinfo.c
rename to scilab/modules/fileio/src/cpp/getfileinfo.cpp
index c457550..a02174b 100644 (file)
@@ -1,41 +1,52 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA
- * ...
+ * Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
  *
  * 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.1-en.txt
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 /*--------------------------------------------------------------------------*/
 #include <string.h> /* strlen */
+#include "filemanager.hxx"
+#include "file.hxx"
+
+extern "C"
+{
 #include "getfileinfo.h"
-#include "filesmanagement.h"
+#include "charEncoding.h"
+#include "MALLOC.h"
+}
 /*--------------------------------------------------------------------------*/
 void C2F(getfileinfo)(int *fd, FILE *fa, int *swap2, int *type, int *mode, char *filename, int *lf, int *ierr)
 {
-    char *filenamefromfd = NULL;
-    if (*fd < 0 || *fd >= GetMaximumFileOpenedInScilab() )
+    const wchar_t *filenamefromfd = NULL;
+    if (*fd < 0)
     {
         *ierr = 1;
         return;
     }
-    if ( GetFileTypeOpenedInScilab(*fd) == 0 )
+
+    types::File* pFile = FileManager::getFile(*fd);
+
+    if (*fd >= FileManager::getFileMaxID() || pFile == NULL || pFile->getFileType() == 0)
     {
         *ierr = 2;
         return;
     }
 
-    *swap2 = GetSwapStatus(*fd);
-    *type = GetFileTypeOpenedInScilab(*fd);
-    *mode = GetFileModeOpenedInScilab(*fd);
-    filenamefromfd = GetFileNameOpenedInScilab(*fd);
+    *swap2 = pFile->getFileSwap();
+    *type = pFile->getFileType();
+    *mode = pFile->getFileModeAsInt();
+    filenamefromfd = pFile->getFilename().c_str();
     if (filenamefromfd)
     {
-        strcpy(filename, GetFileNameOpenedInScilab(*fd));
+        char* pstFileName = wide_string_to_UTF8(filenamefromfd);
+        strcpy(filename, pstFileName);
+        FREE(pstFileName);
     }
     else
     {
similarity index 65%
rename from scilab/modules/fileio/src/c/getfiletype.c
rename to scilab/modules/fileio/src/cpp/getfiletype.cpp
index 731b59b..8c62854 100644 (file)
@@ -1,32 +1,39 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA
- * ...
+ * Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
  *
  * 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.1-en.txt
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 /*--------------------------------------------------------------------------*/
+#include "filemanager.hxx"
+#include "file.hxx"
+
+extern "C"{
 #include "getfiletype.h"
-#include "filesmanagement.h"
+}
 /*--------------------------------------------------------------------------*/
 void C2F(getfiletype)(int *fd, int *type, int *ierr)
 {
-    if (*fd < 0 || *fd >= GetMaximumFileOpenedInScilab() )
+    if (*fd < 0)
     {
         *ierr = 1;
         return;
     }
-    if ( GetFileTypeOpenedInScilab(*fd) == 0 )
+
+    types::File* pFile = FileManager::getFile(*fd);
+
+    if (*fd >= FileManager::getFileMaxID() || pFile == NULL || pFile->getFileType() == 0)
     {
         *ierr = 2;
         return;
     }
-    *type = GetFileTypeOpenedInScilab(*fd);
+
+    *type = pFile->getFileType();
     *ierr = 0;
 }
 /*--------------------------------------------------------------------------*/
index e0f7eb0..a6e97dd 100644 (file)
@@ -23,6 +23,8 @@ extern "C"
 #include "localization.h"
 #include "warningmode.h"
 #include "charEncoding.h"
+
+extern int C2F(clunit)(int* , char*, int*, int);
 }
 /*--------------------------------------------------------------------------*/
 int mcloseCurrentFile()
@@ -60,18 +62,28 @@ int mcloseAll()
 
 int mclose(int _iID)
 {
-    File* pF = FileManager::getFile(_iID);
-    if (pF != NULL)
+    types::File* pFile = FileManager::getFile(_iID);
+    if (pFile != NULL)
     {
-        int iRet = fclose(pF->getFiledesc());
-
-        // this function previously called ferror on a just before fclosed FILE* that could lead to crash at exit, depending on libc implementation.
-        if (iRet != 0)
+        if(pFile->getFileType() == 1)
         {
-            return 1;
+            int iFileNum = -_iID; // -_iID to close file _iID
+            char* stFilename = ""; // file will be closed by this num
+            int iMode = 0; // not used in close mode
+            return C2F(clunit)(&iFileNum, stFilename, &iMode, 1L);
         }
+        else if(pFile->getFileType() == 2)
+        {
+            int iRet = fclose(pFile->getFiledesc());
 
-        FileManager::deleteFile(_iID);
+            // this function previously called ferror on a just before fclosed FILE* that could lead to crash at exit, depending on libc implementation.
+            if (iRet != 0)
+            {
+                return 1;
+            }
+
+            FileManager::deleteFile(_iID);
+        }
     }
     else
     {
@@ -88,70 +100,19 @@ void C2F(mclose) (int *fd, double *res)
     int fd1 = -1;
     *res = 0.0;
 
-    switch ( *fd )
+    switch (*fd)
     {
         case ALL_FILES_DESCRIPTOR :
+        {
             /* closing all opened files */
-            for ( fd1 = 0; fd1 < GetMaximumFileOpenedInScilab(); fd1++)
-            {
-                FILE* stream = GetFileOpenedInScilab(fd1) ;
-                if ( stream )
-                {
-                    int res1 = 1;
-                    res1 = fclose( stream );
-                    // this function previously called ferror on a just before fclosed FILE* that could lead to crash at exit, depending on libc implementation.
-                    if (res1 != 0)
-                    {
-                        *res = 1;
-                    }
-                    C2F(delfile)(&fd1);
-                    /* bug 3897 */
-                    /* initialize file ID */
-                    SetCurrentFileId(-1);
-                }
-            }
-            break;
-
+            mcloseAll();
+        }
+        break;
         default :
         {
-            fd1 = (*fd == -1 ) ? GetCurrentFileId() : Min(Max(*fd, 0), GetMaximumFileOpenedInScilab() - 1);
-            if ( fd1 != -1 )
-            {
-                if ( GetFileOpenedInScilab(fd1) )
-                {
-                    int prevId = -1;
-
-                    if (fclose(GetFileOpenedInScilab(fd1)))
-                    {
-                        *res = (double)ferror(GetFileOpenedInScilab(fd1));
-                    }
-                    C2F(delfile)(&fd1);
-
-                    /* bug 3897 */
-                    /* set as current file previous opened file if exists */
-                    prevId = GetPreviousFileId();
-
-                    if ( GetFileOpenedInScilab(prevId) )
-                    {
-                        SetCurrentFileId(prevId);
-                    }
-                }
-                else
-                {
-                    *res = 0.0;
-                    if (getWarningMode())
-                    {
-                        sciprint(_("%s: Cannot close file whose descriptor is %d: File is not active.\n"), "mclose", fd1);
-                    }
-                }
-            }
-            else
+            if(mclose(*fd))
             {
                 *res = -1.0;
-                if (getWarningMode())
-                {
-                    sciprint(_("%s: Cannot close file whose descriptor is %d: No file to close.\n"), "mclose", fd1);
-                }
             }
         }
     }
index ed9bbf1..d456e33 100644 (file)
@@ -248,7 +248,7 @@ wchar_t **mgetl(int fd, int nbLinesIn, int *nbLinesOut, int *ierr)
 /*--------------------------------------------------------------------------*/
 wchar_t* getLine(wchar_t* _pstLine, int _iLineSize, File* _pFile)
 {
-    if (static_cast<int>(_pFile->getFileModeAsDouble()) % 2 == 1)
+    if (_pFile->getFileModeAsInt() % 2 == 1)
     {
         //binary mode
         return fgetws(_pstLine, _iLineSize, _pFile->getFiledesc());
index 3513269..39fa519 100644 (file)
@@ -28,7 +28,7 @@ wchar_t* mgetstr(int _iFileId, int _iSizeToRead)
 
     if (pF != NULL)
     {
-        if (static_cast<int>(pF->getFileModeAsDouble()) % 2 == 0) //to determine if the file have been opened with binary or text mode
+        if (pF->getFileModeAsInt() % 2 == 0) //to determine if the file have been opened with binary or text mode
         {
             int iSizeRead = 0;
             pwstOut = (wchar_t*)MALLOC((_iSizeToRead + 1) * sizeof(wchar_t));
index 1cfdf92..9976999 100644 (file)
@@ -44,7 +44,13 @@ mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings, BOOL _CR
         pF = FileManager::getFile(_iFileId);
         if (pF)
         {
-            if (pF->getFileModeAsDouble() >= 100 && pF->getFileModeAsDouble() < 200)
+            // file opened with fortran open function
+            if (pF->getFileType() == 1)
+            {
+                return MPUTL_ERROR;
+            }
+
+            if (pF->getFileModeAsInt() >= 100 && pF->getFileModeAsInt() < 200)
             {
                 return MPUTL_NO_WRITE_RIGHT;
             }
index 54a97aa..701da7b 100644 (file)
@@ -33,14 +33,20 @@ long int mtell(int fd)
         return offset;
     }
 
+    FILE* fa = pF->getFiledesc();
+    if (fa == NULL)
+    {
+        return -1;
+    }
+
 #ifdef _MSC_VER
 #if _WIN64
-    offset = (long)_ftelli64(pF->getFiledesc()) ;
+    offset = (long)_ftelli64(fa) ;
 #else
-    offset = ftell(pF->getFiledesc()) ;
+    offset = ftell(fa) ;
 #endif
 #else
-    offset = ftell(pF->getFiledesc()) ;
+    offset = ftell(fa) ;
 #endif
 
     return offset;
index 4e7ec86..28c9654 100644 (file)
@@ -2,6 +2,7 @@
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2006 - INRIA - Allan CORNET
  * Copyright (C) 2009-2010 - DIGITEO - Allan CORNET
+ * Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  */
 
 /*--------------------------------------------------------------------------*/
-#include <string.h>
 #include "funcmanager.hxx"
 #include "context.hxx"
 #include "io_gw.hxx"
-#include "setenvvar.hxx"
 #include "filemanager.hxx"
 #include "string.hxx"
 
@@ -25,33 +24,30 @@ extern "C"
 #include "os_wcsdup.h"
 #include "localization.h"
 #include "Scierror.h"
-}
-/*
-#include <string.h>
-#include "gw_io.h"
-#include "stack-c.h"
-#include "api_scilab.h"
-#include "FileExist.h"
 #include "MALLOC.h"
-#include "charEncoding.h"
-#include "filesmanagement.h"
-#include "freeArrayOfString.h"
-#ifdef _MSC_VER
-#include "strdup_windows.h"
-#endif
-*/
+#include "FileExist.h"
+#include "mclose.h"
+#include "mseek.h"
+
+    extern int C2F(clunit)(int* , char*, int*, int);
+    extern int C2F(rewind_inter)(int*);
+    extern int C2F(backspace_inter)(int*);
+    extern int C2F(read_inter)(int*, char*, int);
+}
 /*--------------------------------------------------------------------------*/
-#define FILE_OPEN_STR "open"
-#define FILE_OLD_STR "old"
+types::Function::ReturnValue sci_file_no_rhs(types::typed_list &in, int _iRetCount, types::typed_list &out);
+types::Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCount, types::typed_list &out);
 /*--------------------------------------------------------------------------*/
+types::Function::ReturnValue sci_file(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    types::String* pSAction = NULL;
 
-using namespace types;
+    if (in.size() > 6)
+    {
+        Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), "file", 0, 6);
+        return types::Function::Error;
+    }
 
-Function::ReturnValue sci_file_no_rhs(types::typed_list &in, int _iRetCount, types::typed_list &out);
-Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCount, types::typed_list &out);
-/*--------------------------------------------------------------------------*/
-Function::ReturnValue sci_file(types::typed_list &in, int _iRetCount, types::typed_list &out)
-{
     if (in.size() == 0)
     {
         return sci_file_no_rhs(in, _iRetCount, out);
@@ -61,265 +57,312 @@ Function::ReturnValue sci_file(types::typed_list &in, int _iRetCount, types::typ
     {
         return sci_file_one_rhs(in, _iRetCount, out);
     }
-    return Function::OK;
-}
 
-//int sci_file(char *fname, void* pvApiCtx)
-//{
-//     if (Rhs == 0)
-//     {
-//             return sci_file_no_rhs(fname, pvApiCtx);
-//     }
-//
-//     if (Rhs == 1)
-//     {
-//             return sci_file_one_rhs(fname, pvApiCtx);
-//     }
-//
-//     if (Rhs >= 3)
-//     {
-//             SciErr sciErr;
-//
-//             int *piAddressVarOne = NULL;
-//             int *piAddressVarTwo = NULL;
-//             int *piAddressVarThree = NULL;
-//
-//             int iType1 = 0;
-//             int iType2 = 0;
-//             int iType3 = 0;
-//
-//             sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//
-//             sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//
-//             sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddressVarThree);
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//
-//             sciErr = getVarType(pvApiCtx, piAddressVarOne, &iType1);
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//
-//             sciErr = getVarType(pvApiCtx, piAddressVarTwo, &iType2);
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//
-//             sciErr = getVarType(pvApiCtx, piAddressVarThree, &iType3);
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//
-//             if ( (iType1 == sci_strings) && (iType2 == sci_strings) && (iType3 == sci_strings) )
-//             {
-//                     char *pStVarOne = NULL;
-//                     int lenStVarOne = 0;
-//
-//                     wchar_t *pStVarTwo = NULL;
-//                     int lenStVarTwo = 0;
-//
-//                     char *pStVarThree = NULL;
-//                     int lenStVarThree = 0;
-//
-//                     int m1 = 0, n1 = 0;
-//                     int m2 = 0, n2 = 0;
-//                     int m3 = 0, n3 = 0;
-//
-//                     sciErr = getVarDimension(pvApiCtx, piAddressVarOne, &m1, &n1);
-//                     if(sciErr.iErr)
-//                     {
-//                             printError(&sciErr, 0);
-//                             return 0;
-//                     }
-//
-//                     if ( (m1 != n1) && (n1 != 1) )
-//                     {
-//                             Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 1);
-//                             return 0;
-//                     }
-//
-//                     sciErr = getVarDimension(pvApiCtx, 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 string expected.\n"), fname, 2);
-//                             return 0;
-//                     }
-//
-//                     sciErr = getVarDimension(pvApiCtx, 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 string expected.\n"), fname, 3);
-//                             return 0;
-//                     }
-//
-//                     // get lenStVarOne value
-//                     sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, &pStVarOne);
-//                     if(sciErr.iErr)
-//                     {
-//                             printError(&sciErr, 0);
-//                             return 0;
-//                     }
-//
-//                     // get value of first argument
-//                     pStVarOne = (char*)MALLOC(sizeof(char)*(lenStVarOne + 1));
-//                     if (pStVarOne == NULL)
-//                     {
-//                             Scierror(999,_("%s: Memory allocation error.\n"),fname);
-//                             return 0;
-//                     }
-//
-//                     sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, &pStVarOne);
-//                     if(sciErr.iErr)
-//                     {
-//                             FREE(pStVarOne); pStVarOne = NULL;
-//                             printError(&sciErr, 0);
-//                             return 0;
-//                     }
-//
-//                     if (strcmp(pStVarOne, FILE_OPEN_STR) == 0)
-//                     {
-//                             FREE(pStVarOne); pStVarOne = NULL;
-//
-//                             // get lenStVarThree value
-//                             sciErr = getMatrixOfString(pvApiCtx, piAddressVarThree, &m3, &n3, &lenStVarThree, &pStVarThree);
-//                             if(sciErr.iErr)
-//                             {
-//                                     printError(&sciErr, 0);
-//                                     return 0;
-//                             }
-//
-//                             // get value of third argument
-//                             pStVarThree = (char*)MALLOC(sizeof(char)*(lenStVarThree + 1));
-//                             if (pStVarThree == NULL)
-//                             {
-//                                     Scierror(999,_("%s: Memory allocation error.\n"),fname);
-//                                     return 0;
-//                             }
-//
-//                             sciErr = getMatrixOfString(pvApiCtx, piAddressVarThree, &m3, &n3, &lenStVarThree, &pStVarThree);
-//                             if(sciErr.iErr)
-//                             {
-//                                     FREE(pStVarThree); pStVarThree = NULL;
-//                                     printError(&sciErr, 0);
-//                                     return 0;
-//                             }
-//
-//                             if (strcmp(pStVarThree, FILE_OLD_STR) == 0)
-//                             {
-//                                     FREE(pStVarThree); pStVarThree = NULL;
-//
-//                                     // get lenStVarTwo value
-//                                     sciErr = getMatrixOfWideString(pvApiCtx, piAddressVarTwo, &m2, &n2, &lenStVarTwo, &pStVarTwo);
-//                                     if(sciErr.iErr)
-//                                     {
-//                                             printError(&sciErr, 0);
-//                                             return 0;
-//                                     }
-//
-//                                     // get value of second argument
-//                                     pStVarTwo = (wchar_t*)MALLOC(sizeof(wchar_t)*(lenStVarTwo + 1));
-//                                     if (pStVarTwo == NULL)
-//                                     {
-//                                             Scierror(999,_("%s: Memory allocation error.\n"),fname);
-//                                             return 0;
-//                                     }
-//
-//                                     sciErr = getMatrixOfWideString(pvApiCtx, piAddressVarTwo, &m2, &n2, &lenStVarTwo, &pStVarTwo);
-//                                     if(sciErr.iErr)
-//                                     {
-//                                             FREE(pStVarTwo); pStVarTwo = NULL;
-//                                             printError(&sciErr, 0);
-//                                             return 0;
-//                                     }
-//
-//                                     if (!FileExistW(pStVarTwo))
-//                                     {
-//                                             if (Lhs == 2)
-//                                             {
-//                                                     double dOutErrCode = 240.;
-//                                                     int m_out = 1,  n_out = 1;
-//
-//                                                     sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 1, 0, 0, NULL);
-//                                                     if(sciErr.iErr)
-//                                                     {
-//                                                             printError(&sciErr, 0);
-//                                                             return 0;
-//                                                     }
-//
-//                                                     sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 2, m_out, n_out, &dOutErrCode);
-//                                                     if(sciErr.iErr)
-//                                                     {
-//                                                             printError(&sciErr, 0);
-//                                                             return 0;
-//                                                     }
-//
-//                                                     LhsVar(2) = Rhs + 2;
-//                                                     LhsVar(1) = Rhs + 1;
-//                                                     C2F(putlhsvar)();
-//                                             }
-//                                             else
-//                                             {
-//                                                     char *filename = wide_string_to_UTF8(pStVarTwo);
-//                                                     if (filename)
-//                                                     {
-//                                                             Scierror(240, _("%s: The file \"%s\" does not exist.\n"),fname, filename);
-//                                                             FREE(filename);
-//                                                             filename = NULL;
-//                                                     }
-//                                                     else
-//                                                     {
-//                                                             Scierror(240, _("%s: The file does not exist.\n"),fname);
-//                                                     }
-//                                             }
-//                                             return 0;
-//                                     }
-//
-//                                     FREE(pStVarTwo); pStVarTwo = NULL;
-//                             }
-//
-//                             FREE(pStVarThree); pStVarThree = NULL;
-//                     }
-//
-//                     FREE(pStVarOne); pStVarOne = NULL;
-//             }
-//     }
-//
-//     C2F(intfile)();
-//     return 0;
-//}
-///*--------------------------------------------------------------------------*/
+    // get action
+    if (in[0]->isString() == false)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d : A string expected.\n"), "file", 1);
+        return types::Function::Error;
+    }
+
+    pSAction = in[0]->getAs<types::String>();
+
+    if (pSAction->isScalar() == false)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d : A single string expected.\n"), "file", 1);
+        return types::Function::Error;
+    }
+
+    if (wcscmp(pSAction->get(0), L"open") == 0)
+    {
+        types::String* pSPath   = NULL;
+        types::String* pSOption = NULL;
+        types::Double* pSRecl   = NULL;
+
+        int iStatus = 0;
+        int iAccess = 0;
+        int iForm   = 0;
+        int iRecl   = 0;
+
+        int piMode[2] = {0, 0};
+
+        // get path
+        if (in[1]->isString() == false)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d : A string expected.\n"), "file", 2);
+            return types::Function::Error;
+        }
+
+        pSPath = in[1]->getAs<types::String>();
+
+        if (pSPath->isScalar() == false)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d : A single string expected.\n"), "file", 2);
+            return types::Function::Error;
+        }
+
+        // get optional inputs
+        for (int i = 2; i < in.size(); i++)
+        {
+            if (in[i]->isString())
+            {
+                pSOption = in[i]->getAs<types::String>();
+            }
+            else if (i != 2 && in[i]->isDouble())
+            {
+                pSRecl = in[i]->getAs<types::Double>();
+                if (pSRecl->isScalar() == false)
+                {
+                    Scierror(999, _("%s: Wrong type for input argument #%d : A scalar expected.\n"), "file", i + 1);
+                    return types::Function::Error;
+                }
+
+                iRecl = (int)pSRecl->get(0);
+                piMode[1] = iRecl;
+                continue;
+            }
+            else
+            {
+                Scierror(999, _("%s: Wrong type for input argument #%d : A string expected.\n"), "file", i + 1);
+                return types::Function::Error;
+            }
+
+            if (pSOption->isScalar() == false)
+            {
+                Scierror(999, _("%s: Wrong type for input argument #%d : A single string expected.\n"), "file", i + 1);
+                return types::Function::Error;
+            }
+
+            if (wcscmp(pSOption->get(0), L"new") == 0)
+            {
+                iStatus = 0;
+            }
+            else if (wcscmp(pSOption->get(0), L"old") == 0)
+            {
+                iStatus = 1;
+                // file must already exists.
+                if (FileExistW(pSPath->get(0)) == false)
+                {
+                    if (_iRetCount == 2)
+                    {
+                        out.push_back(types::Double::Empty());
+                        out.push_back(new types::Double(240));
+                        return types::Function::OK;
+                    }
+                    else
+                    {
+                        char* pstrFilename = wide_string_to_UTF8(pSPath->get(0));
+                        if (pstrFilename)
+                        {
+                            Scierror(240, _("%s: The file \"%s\" does not exist.\n"), "file", pstrFilename);
+                            FREE(pstrFilename);
+                            pstrFilename = NULL;
+                        }
+                        else
+                        {
+                            Scierror(240, _("%s: The file does not exist.\n"), "file");
+                        }
+
+                        return types::Function::Error;
+                    }
+                }
+            }
+            else if (wcscmp(pSOption->get(0), L"scratch") == 0)
+            {
+                iStatus = 2;
+            }
+            else if (wcscmp(pSOption->get(0), L"unknown") == 0)
+            {
+                iStatus = 3;
+            }
+            else if (wcscmp(pSOption->get(0), L"sequential") == 0)
+            {
+                iAccess = 0;
+            }
+            else if (wcscmp(pSOption->get(0), L"direct") == 0)
+            {
+                iAccess = 1;
+            }
+            else if (wcscmp(pSOption->get(0), L"formatted") == 0)
+            {
+                iForm = 0;
+            }
+            else if (wcscmp(pSOption->get(0), L"unformatted") == 0)
+            {
+                iForm = 1;
+            }
+            else
+            {
+                Scierror(999, _("%s: Wrong value for input argument #%d.\n"), "file", i + 1);
+                return types::Function::Error;
+            }
+        }
+
+        piMode[0] = iStatus + 10 * (iAccess + 10 * iForm);
+        int lunit = 0; // file unit. 0 mean we open the file by this name.
+        char* pstFilename = wide_string_to_UTF8(pSPath->get(0));
+        int iErr = C2F(clunit)(&lunit, pstFilename, piMode, (int)strlen(pstFilename));
+        if (iErr)
+        {
+            if (_iRetCount == 1)
+            {
+                switch (iErr)
+                {
+                    case 65  :
+                        Scierror(iErr, _("%s: %d logical unit already used.\n"), "file", lunit);
+                        break;
+                    case 66  :
+                        Scierror(iErr, _("%s: Too many files opened!\n"), "file");
+                        break;
+                    case 67  :
+                        Scierror(iErr, _("%s: Unknown file format.\n"), "file");
+                        break;
+                    case 240 :
+                        Scierror(iErr, _("%s: File \"%s\" already exists or directory write access denied.\n"), "file", pstFilename);
+                        break;
+                    case 241 :
+                        Scierror(iErr, _("%s: File \"%s\" does not exist or read access denied.\n"), "file", pstFilename);
+                        break;
+                    default  :
+                        Scierror(iErr, _("%s: Can not open File \"%s\"\n"), "file", pstFilename);
+                }
+
+                return types::Function::Error;
+            }
+            else
+            {
+                out.push_back(types::Double::Empty());
+                out.push_back(new types::Double((double)iErr));
+                return types::Function::OK;
+            }
+        }
+
+        out.push_back(new types::Double((double)lunit));
+        if (_iRetCount == 2)
+        {
+            out.push_back(new types::Double(0.0));
+        }
+
+        FREE(pstFilename);
+    }
+    else if (wcscmp(pSAction->get(0), L"close") == 0 ||
+             wcscmp(pSAction->get(0), L"rewind") == 0 ||
+             wcscmp(pSAction->get(0), L"backspace") == 0 ||
+             wcscmp(pSAction->get(0), L"last") == 0)
+    {
+        if (_iRetCount != 1)
+        {
+            Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), "file", 1);
+            return types::Function::Error;
+        }
+
+        if (in.size() != 2)
+        {
+            Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "file", 2);
+            return types::Function::Error;
+        }
+
+        if (in[1]->isDouble() == false)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d : A matrix expected.\n"), "file", 2);
+            return types::Function::Error;
+        }
+
+        types::Double* pDblFileUnit = in[1]->getAs<types::Double>();
+        double* pdblUnit = pDblFileUnit->get();
+
+        if (wcscmp(pSAction->get(0), L"close") == 0)
+        {
+            for (int i = 0; i < pDblFileUnit->getSize(); i++)
+            {
+                int iErr = mclose((int)(pdblUnit[i]));
+                if (iErr)
+                {
+                    Scierror(999, _("%s: Cannot close file %d.\n"), "file", (int)pdblUnit[i]);
+                    return types::Function::Error;
+                }
+            }
+        }
+        else if (wcscmp(pSAction->get(0), L"rewind") == 0)
+        {
+            int iFileUnit = (int)pdblUnit[0];
+            types::File* pFile = FileManager::getFile(iFileUnit);
+
+            if (pFile && pFile->getFileType() == 2)
+            {
+                mseek(iFileUnit, 0, SEEK_SET);
+            }
+            else if (pFile && pFile->getFileType() == 1)
+            {
+                C2F(rewind_inter)(&iFileUnit);
+            }
+            else
+            {
+                Scierror(67, _("%s: Unknown file format.\n"), "file");
+                return types::Function::Error;
+            }
+        }
+        else if (wcscmp(pSAction->get(0), L"backspace") == 0)
+        {
+            int iFileUnit = (int)pdblUnit[0];
+            types::File* pFile = FileManager::getFile(iFileUnit);
+
+            if (pFile && pFile->getFileType() == 2)
+            {
+                Scierror(999, _("%s: Wrong input argument #%d.\n"), "file", 1);
+                return types::Function::Error;
+            }
+            else if (pFile && pFile->getFileType() == 1)
+            {
+                C2F(backspace_inter)(&iFileUnit);
+            }
+            else
+            {
+                Scierror(67, _("%s: Unknown file format.\n"), "file");
+                return types::Function::Error;
+            }
+        }
+        else if (wcscmp(pSAction->get(0), L"last") == 0)
+        {
+            int iFileUnit = (int)pdblUnit[0];
+            types::File* pFile = FileManager::getFile(iFileUnit);
+
+            if (pFile && pFile->getFileType() == 2)
+            {
+                mseek(iFileUnit, 0, SEEK_END);
+            }
+            else if (pFile && pFile->getFileType() == 1)
+            {
+                int iErr = 0;
+                while (iErr == 0)
+                {
+                    iErr = C2F(read_inter)(&iFileUnit, "(a)", 1L);
+                }
+
+                if (iErr == 2)
+                {
+                    Scierror(999, _("%s: \n"), "file");
+                    return types::Function::Error;
+                }
+
+                C2F(backspace_inter)(&iFileUnit);
+            }
+            else
+            {
+                Scierror(67, _("%s: Unknown file format.\n"), "file");
+                return types::Function::Error;
+            }
+        }
+    }
+    else
+    {
+        Scierror(49, _("%s: Wrong value for input argument #%d: \"%s\", \"%s\", \"%s\", \"%s\", \"%s\" \n"), "file", 1, "open", "close", "rewind", "backspace", "last");
+        return types::Function::Error;
+    }
+
+    return types::Function::OK;
+}
+/*--------------------------------------------------------------------------*/
 Function::ReturnValue sci_file_no_rhs(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
     int iCount = FileManager::getOpenedCount();
@@ -453,7 +496,14 @@ Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCount, ty
 
     if (_iRetCount > 3) /* mod */
     {
-        out.push_back(new Double(pF->getFileModeAsDouble()));
+        if (pF->getFileType() == 1)
+        {
+            out.push_back(new Double((double)pF->getFileFortranMode()));
+        }
+        else // if(pF->getFileType() == 2)
+        {
+            out.push_back(new Double((double)pF->getFileModeAsInt()));
+        }
     }
 
     if (_iRetCount > 4) /* swap */
@@ -462,202 +512,3 @@ Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCount, ty
     }
     return Function::OK;
 }
-//static int sci_file_one_rhs(char *fname, void* pvApiCtx)
-//{
-//     SciErr sciErr;
-//
-//     int iID = 0;
-//     int m1 = 0, n1 = 0;
-//     int iType = 0;
-//     int *piAddressVarOne = NULL;
-//     double *pdVarOne = NULL;
-//
-//     int m_out = 0;
-//     int n_out = 0;
-//
-//     /* get Address of inputs */
-//     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
-//     if(sciErr.iErr)
-//     {
-//             printError(&sciErr, 0);
-//             return 0;
-//     }
-//
-//     sciErr = getVarType(pvApiCtx, piAddressVarOne, &iType);
-//     if(sciErr.iErr)
-//     {
-//             printError(&sciErr, 0);
-//             return 0;
-//     }
-//
-//     /* check input type */
-//     if ( iType != sci_matrix )
-//     {
-//             Scierror(201,_("%s: Wrong type for input argument #%d: A scalar expected.\n"),fname,1);
-//             return 0;
-//     }
-//
-//     sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarOne,&m1,&n1,&pdVarOne);
-//     if(sciErr.iErr)
-//     {
-//             printError(&sciErr, 0);
-//             return 0;
-//     }
-//
-//     if( n1 != 1 || m1 != 1)
-//     {
-//             Scierror(999,_("%s: Wrong size for input argument #%d: A scalar expected.\n"),fname,1);
-//             return 0;
-//     }
-//
-//     iID = (int) *pdVarOne;
-//
-//     if (*pdVarOne != (double)iID)
-//     {
-//             Scierror(999,_("%s: Wrong value for input argument #%d: A integer expected.\n"),fname,1);
-//             return 0;
-//     }
-//
-//     /* Lhs = 0 ID */
-//     if (GetFileTypeOpenedInScilab(iID) != 0)
-//     {
-//             m_out = 1;
-//             n_out = 1;
-//             sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 1, m_out, n_out, pdVarOne);
-//     }
-//     else
-//     {
-//             /* returns [] */
-//             m_out = 0;
-//             n_out = 0;
-//             sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 1, m_out, n_out, NULL);
-//     }
-//
-//     if(sciErr.iErr)
-//     {
-//             printError(&sciErr, 0);
-//             return 0;
-//     }
-//
-//     LhsVar(1) = Rhs + 1;
-//
-//     if (Lhs > 1) /* Type */
-//     {
-//             if (GetFileTypeOpenedInScilab(iID) != 0)
-//             {
-//                     char *TypeIdAsString = GetFileTypeOpenedInScilabAsString(iID);
-//                     m_out = 1;
-//                     n_out = 1;
-//                     sciErr = createMatrixOfString(pvApiCtx, Rhs + 2, m_out, n_out, &TypeIdAsString);
-//                     FREE(TypeIdAsString);
-//                     TypeIdAsString = NULL;
-//             }
-//             else
-//             {
-//                     /* returns [] */
-//                     m_out = 0;
-//                     n_out = 0;
-//                     sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 2, m_out, n_out, NULL);
-//             }
-//
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//
-//             LhsVar(2) = Rhs + 2;
-//     }
-//
-//     if (Lhs > 2) /* name */
-//     {
-//             if (GetFileTypeOpenedInScilab(iID) != 0)
-//             {
-//                     char *filename = NULL;
-//                     m_out = 1;
-//                     n_out = 1;
-//                     if (GetFileNameOpenedInScilab(iID) == NULL)
-//                     {
-//                             filename = os_strdup("");
-//                     }
-//                     else
-//                     {
-//                             filename = os_strdup(GetFileNameOpenedInScilab(iID));
-//                     }
-//
-//                     sciErr = createMatrixOfString(pvApiCtx, Rhs + 3, m_out, n_out, &filename);
-//                     FREE(filename);
-//                     filename = NULL;
-//             }
-//             else
-//             {
-//                     /* returns [] */
-//                     m_out = 0;
-//                     n_out = 0;
-//                     sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 3, m_out, n_out, NULL);
-//             }
-//
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//
-//             LhsVar(3) = Rhs + 3;
-//     }
-//
-//     if (Lhs > 3)  /* mod */
-//     {
-//             if (GetFileTypeOpenedInScilab(iID) != 0)
-//             {
-//                     double ModeId = (double)GetFileModeOpenedInScilab(iID);
-//                     m_out = 1;
-//                     n_out = 1;
-//                     sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 4, m_out, n_out, &ModeId);
-//             }
-//             else
-//             {
-//                     /* returns [] */
-//                     m_out = 0;
-//                     n_out = 0;
-//                     sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 4, m_out, n_out, NULL);
-//             }
-//
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//
-//             LhsVar(4) = Rhs + 4;
-//     }
-//
-//     if (Lhs > 4) /* swap */
-//     {
-//             if (GetFileTypeOpenedInScilab(iID) != 0)
-//             {
-//                     double SwapId = (double)GetSwapStatus(iID);
-//                     m_out = 1;
-//                     n_out = 1;
-//                     sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 5, m_out, n_out, &SwapId);
-//             }
-//             else
-//             {
-//                     /* returns [] */
-//                     m_out = 0;
-//                     n_out = 0;
-//                     sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 5, m_out, n_out, NULL);
-//             }
-//
-//             if(sciErr.iErr)
-//             {
-//                     printError(&sciErr, 0);
-//                     return 0;
-//             }
-//             LhsVar(5) = Rhs + 5;
-//     }
-//
-//     C2F(putlhsvar)();
-//     return 0;
-//}
-/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/io/src/cpp/core_f_Import.def b/scilab/modules/io/src/cpp/core_f_Import.def
new file mode 100644 (file)
index 0000000..e9653c4
--- /dev/null
@@ -0,0 +1,11 @@
+       LIBRARY    core_f.dll
+
+
+EXPORTS
+;
+;core
+;
+clunit_
+read_inter_
+rewind_inter_
+backspace_inter_
index 53ef8df..2e88778 100644 (file)
       <SubSystem>Windows</SubSystem>
       <TargetMachine>MachineX86</TargetMachine>
       <RandomizedBaseAddress>false</RandomizedBaseAddress>
-      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <PreLinkEvent>
-      <Command>
-      </Command>
+      <Command>lib /DEF:"$(ProjectDir)core_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core_f.lib" 1&gt;NUL 2&gt;NUL</Command>
     </PreLinkEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
       <SubSystem>Windows</SubSystem>
       <TargetMachine>MachineX64</TargetMachine>
       <RandomizedBaseAddress>false</RandomizedBaseAddress>
-      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <PreLinkEvent>
-      <Command>
-      </Command>
+      <Command>lib /DEF:"$(ProjectDir)core_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core_f.lib" 1&gt;NUL 2&gt;NUL</Command>
     </PreLinkEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <TargetMachine>MachineX86</TargetMachine>
       <RandomizedBaseAddress>false</RandomizedBaseAddress>
-      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <PreLinkEvent>
-      <Command>
-      </Command>
+      <Command>lib /DEF:"$(ProjectDir)core_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core_f.lib" 1&gt;NUL 2&gt;NUL</Command>
     </PreLinkEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <TargetMachine>MachineX64</TargetMachine>
       <RandomizedBaseAddress>false</RandomizedBaseAddress>
-      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <PreLinkEvent>
-      <Command>
-      </Command>
+      <Command>lib /DEF:"$(ProjectDir)core_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core_f.lib" 1&gt;NUL 2&gt;NUL</Command>
     </PreLinkEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="core_f_Import.def" />
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
index 00b73e8..59bb100 100644 (file)
@@ -13,6 +13,9 @@
       <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
       <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
     </Filter>
+    <Filter Include="Libraries Dependencies">
+      <UniqueIdentifier>{2231fea1-d6c6-45c4-a8c4-0a813af90f5b}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="io_gw.cpp">
@@ -81,4 +84,9 @@
     <Library Include="..\..\..\..\bin\libintl.lib" />
     <Library Include="..\..\..\..\bin\libxml2.lib" />
   </ItemGroup>
+  <ItemGroup>
+    <None Include="core_f_Import.def">
+      <Filter>Libraries Dependencies</Filter>
+    </None>
+  </ItemGroup>
 </Project>
\ No newline at end of file
index 1b8da85..9983b77 100644 (file)
@@ -26,7 +26,10 @@ public :
 
     void                        setFileMode(std::wstring _pstMode);
     std::wstring&               getFileMode();
-    double                      getFileModeAsDouble();
+    void                        setFileModeAsInt(int _iMode);
+    int                         getFileModeAsInt();
+    void                        setFileFortranMode(int _iMode);
+    int                         getFileFortranMode();
 
     void                        setFileDesc(FILE* _fileDesc);
     FILE*                       getFiledesc();
@@ -51,6 +54,7 @@ private :
     FILE*                       m_fileDesc;
     int                         m_iSwap; /* swap status for each file */
     std::wstring                m_pstMode; /* mode for each file */
+    int                         m_iFortranMode; /* mode for file opened with fortran open*/
     int                         m_iType; /* type (Fortran,C) for each file must be zero initialized */
     std::wstring                m_stFilename; /* name for each file */
 
index d8a8e30..3cc5273 100644 (file)
@@ -26,7 +26,8 @@ File::File()
     m_fileDesc = NULL;
     m_iSwap = 0;
     m_pstMode = L"";
-    m_iType = 0;
+    m_iFortranMode = -1; // see clunit.f
+    m_iType = 0; // 1 : fortran open   2 : c open
     m_stFilename = L"";
 }
 
@@ -54,37 +55,73 @@ std::wstring& File::getFileMode()
     return m_pstMode;
 }
 
-double File::getFileModeAsDouble()
+int File::getFileModeAsInt()
 {
-    double dblMode  = 0;
-    double dblPlus  = 0;
-    double dblBin   = 0;
+    int iMode  = 0;
+    int iPlus  = 0;
+    int iBin   = 0;
 
     for (int i = 0 ; i < wcslen(m_pstMode.c_str()) ; i++)
     {
         if (m_pstMode[i] == L'r')
         {
-            dblMode = 1;
+            iMode = 1;
         }
         else if (m_pstMode[i] == L'w')
         {
-            dblMode = 2;
+            iMode = 2;
         }
         else if (m_pstMode[i] == L'a')
         {
-            dblMode = 3;
+            iMode = 3;
         }
         else if (m_pstMode[i] == L'+')
         {
-            dblPlus = 1;
+            iPlus = 1;
         }
         else if (m_pstMode[i] == L'b')
         {
-            dblBin = 1;
+            iBin = 1;
         }
     }
 
-    return 100 * dblMode + 10 * dblPlus + dblBin;
+    return 100 * iMode + 10 * iPlus + iBin;
+}
+
+void File::setFileModeAsInt(int _iMode)
+{
+    int iMode  = (int)(_iMode / 100);
+    int iPlus  = (int)((_iMode - iMode * 100) / 10);
+    int iBin   = _iMode - iMode * 100 - iPlus * 10;
+
+    m_pstMode = L"";
+
+    switch(iMode)
+    {
+        case 2 : m_pstMode += L"w"; break;
+        case 3 : m_pstMode += L"a"; break;
+        default: m_pstMode += L"r"; // default mode "rb"
+    }
+
+    if(iPlus)
+    {
+        m_pstMode += L"+";
+    }
+
+    if(iBin)
+    {
+        m_pstMode += L"b";
+    }
+}
+
+void File::setFileFortranMode(int _iMode)
+{
+    m_iFortranMode = _iMode;
+}
+
+int File::getFileFortranMode()
+{
+    return m_iFortranMode;
 }
 
 void File::setFileSwap(int _iSwap)