archiveList complete with gateways, primitives, test and help 17/16717/7
Kartik Gupta [Sun, 21 Jun 2015 10:54:29 +0000 (15:54 +0530)]
Change-Id: I019804a7643f7ff044a086feb64e0653bf0d3731

16 files changed:
scilab/modules/fileio/Makefile.am
scilab/modules/fileio/Makefile.in
scilab/modules/fileio/fileio.vcxproj
scilab/modules/fileio/fileio.vcxproj.filters
scilab/modules/fileio/help/en_US/archiveList.xml [new file with mode: 0644]
scilab/modules/fileio/includes/archive_list.h [new file with mode: 0644]
scilab/modules/fileio/includes/gw_fileio.h
scilab/modules/fileio/sci_gateway/c/gw_fileio.c
scilab/modules/fileio/sci_gateway/c/sci_archive_list.c [new file with mode: 0644]
scilab/modules/fileio/sci_gateway/fileio_gateway.xml
scilab/modules/fileio/src/c/archive_list.c [new file with mode: 0644]
scilab/modules/fileio/src/c/archive_list.h [new file with mode: 0644]
scilab/modules/fileio/tests/unit_tests/archiveList.dia.ref [new file with mode: 0644]
scilab/modules/fileio/tests/unit_tests/archiveList.tst [new file with mode: 0644]
scilab/modules/fileio/tests/unit_tests/example.tar [new file with mode: 0644]
scilab/modules/fileio/tests/unit_tests/example.tar.gz [new file with mode: 0644]

index 6866051..0b4e92a 100644 (file)
@@ -57,7 +57,8 @@ src/c/fscanfMat.c \
 src/c/fprintfMat.c \
 src/c/createtempfilename.c \
 src/c/dlManager.c \
-src/c/convert_tools.c
+src/c/convert_tools.c \
+src/c/archive_list.c 
 
 GATEWAY_SOURCES = \
 sci_gateway/c/gw_fileio.c \
@@ -107,8 +108,8 @@ sci_gateway/c/sci_isfile.c \
 sci_gateway/c/sci_mputl.c \
 sci_gateway/c/sci_tempname.c \
 sci_gateway/c/sci_getURL.c \
-sci_gateway/c/sci_splitURL.c
-
+sci_gateway/c/sci_splitURL.c \
+sci_gateway/c/sci_archive_list.c 
 
 libscifileio_la_CPPFLAGS = -I$(srcdir)/includes/ \
                                -I$(srcdir)/src/c/ \
index 778e151..b306a67 100644 (file)
@@ -222,7 +222,8 @@ am__objects_1 = src/c/libscifileio_algo_la-FileExist.lo \
        src/c/libscifileio_algo_la-fprintfMat.lo \
        src/c/libscifileio_algo_la-createtempfilename.lo \
        src/c/libscifileio_algo_la-dlManager.lo \
-       src/c/libscifileio_algo_la-convert_tools.lo
+       src/c/libscifileio_algo_la-convert_tools.lo \
+       src/c/libscifileio_algo_la-archive_list.lo
 am_libscifileio_algo_la_OBJECTS = $(am__objects_1)
 libscifileio_algo_la_OBJECTS = $(am_libscifileio_algo_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -280,7 +281,8 @@ am__objects_2 = sci_gateway/c/libscifileio_la-gw_fileio.lo \
        sci_gateway/c/libscifileio_la-sci_mputl.lo \
        sci_gateway/c/libscifileio_la-sci_tempname.lo \
        sci_gateway/c/libscifileio_la-sci_getURL.lo \
-       sci_gateway/c/libscifileio_la-sci_splitURL.lo
+       sci_gateway/c/libscifileio_la-sci_splitURL.lo \
+       sci_gateway/c/libscifileio_la-sci_archive_list.lo
 am_libscifileio_la_OBJECTS = $(am__objects_2)
 libscifileio_la_OBJECTS = $(am_libscifileio_la_OBJECTS)
 @MAINTAINER_MODE_FALSE@am_libscifileio_la_rpath =
@@ -681,7 +683,8 @@ src/c/fscanfMat.c \
 src/c/fprintfMat.c \
 src/c/createtempfilename.c \
 src/c/dlManager.c \
-src/c/convert_tools.c
+src/c/convert_tools.c \
+src/c/archive_list.c 
 
 GATEWAY_SOURCES = \
 sci_gateway/c/gw_fileio.c \
@@ -731,7 +734,8 @@ sci_gateway/c/sci_isfile.c \
 sci_gateway/c/sci_mputl.c \
 sci_gateway/c/sci_tempname.c \
 sci_gateway/c/sci_getURL.c \
-sci_gateway/c/sci_splitURL.c
+sci_gateway/c/sci_splitURL.c \
+sci_gateway/c/sci_archive_list.c 
 
 libscifileio_la_CPPFLAGS = -I$(srcdir)/includes/ \
                                -I$(srcdir)/src/c/ \
@@ -1049,6 +1053,8 @@ src/c/libscifileio_algo_la-dlManager.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
 src/c/libscifileio_algo_la-convert_tools.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
+src/c/libscifileio_algo_la-archive_list.lo: src/c/$(am__dirstamp) \
+       src/c/$(DEPDIR)/$(am__dirstamp)
 
 libscifileio-algo.la: $(libscifileio_algo_la_OBJECTS) $(libscifileio_algo_la_DEPENDENCIES) $(EXTRA_libscifileio_algo_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) $(am_libscifileio_algo_la_rpath) $(libscifileio_algo_la_OBJECTS) $(libscifileio_algo_la_LIBADD) $(LIBS)
@@ -1202,6 +1208,9 @@ sci_gateway/c/libscifileio_la-sci_getURL.lo:  \
 sci_gateway/c/libscifileio_la-sci_splitURL.lo:  \
        sci_gateway/c/$(am__dirstamp) \
        sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/c/libscifileio_la-sci_archive_list.lo:  \
+       sci_gateway/c/$(am__dirstamp) \
+       sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
 
 libscifileio.la: $(libscifileio_la_OBJECTS) $(libscifileio_la_DEPENDENCIES) $(EXTRA_libscifileio_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) $(am_libscifileio_la_rpath) $(libscifileio_la_OBJECTS) $(libscifileio_la_LIBADD) $(LIBS)
@@ -1217,6 +1226,7 @@ distclean-compile:
        -rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscifileio_la-gw_fileio.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_archive_list.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_basename.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_chdir.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_copyfile.Plo@am__quote@
@@ -1269,6 +1279,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscifileio_algo_la-Status2Mode.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscifileio_algo_la-URIFileToFilename.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscifileio_algo_la-addfile.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscifileio_algo_la-archive_list.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscifileio_algo_la-basename.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscifileio_algo_la-cluni0.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscifileio_algo_la-convert_tools.Plo@am__quote@
@@ -1721,6 +1732,13 @@ src/c/libscifileio_algo_la-convert_tools.lo: src/c/convert_tools.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 src/c/libscifileio_algo_la-convert_tools.lo `test -f 'src/c/convert_tools.c' || echo '$(srcdir)/'`src/c/convert_tools.c
 
+src/c/libscifileio_algo_la-archive_list.lo: src/c/archive_list.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 src/c/libscifileio_algo_la-archive_list.lo -MD -MP -MF src/c/$(DEPDIR)/libscifileio_algo_la-archive_list.Tpo -c -o src/c/libscifileio_algo_la-archive_list.lo `test -f 'src/c/archive_list.c' || echo '$(srcdir)/'`src/c/archive_list.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscifileio_algo_la-archive_list.Tpo src/c/$(DEPDIR)/libscifileio_algo_la-archive_list.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/archive_list.c' object='src/c/libscifileio_algo_la-archive_list.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 src/c/libscifileio_algo_la-archive_list.lo `test -f 'src/c/archive_list.c' || echo '$(srcdir)/'`src/c/archive_list.c
+
 sci_gateway/c/libscifileio_la-gw_fileio.lo: sci_gateway/c/gw_fileio.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscifileio_la-gw_fileio.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscifileio_la-gw_fileio.Tpo -c -o sci_gateway/c/libscifileio_la-gw_fileio.lo `test -f 'sci_gateway/c/gw_fileio.c' || echo '$(srcdir)/'`sci_gateway/c/gw_fileio.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscifileio_la-gw_fileio.Tpo sci_gateway/c/$(DEPDIR)/libscifileio_la-gw_fileio.Plo
@@ -2057,6 +2075,13 @@ sci_gateway/c/libscifileio_la-sci_splitURL.lo: sci_gateway/c/sci_splitURL.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_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscifileio_la-sci_splitURL.lo `test -f 'sci_gateway/c/sci_splitURL.c' || echo '$(srcdir)/'`sci_gateway/c/sci_splitURL.c
 
+sci_gateway/c/libscifileio_la-sci_archive_list.lo: sci_gateway/c/sci_archive_list.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscifileio_la-sci_archive_list.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_archive_list.Tpo -c -o sci_gateway/c/libscifileio_la-sci_archive_list.lo `test -f 'sci_gateway/c/sci_archive_list.c' || echo '$(srcdir)/'`sci_gateway/c/sci_archive_list.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_archive_list.Tpo sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_archive_list.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sci_gateway/c/sci_archive_list.c' object='sci_gateway/c/libscifileio_la-sci_archive_list.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_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscifileio_la-sci_archive_list.lo `test -f 'sci_gateway/c/sci_archive_list.c' || echo '$(srcdir)/'`sci_gateway/c/sci_archive_list.c
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index d315c16..d569f37 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">
@@ -208,6 +208,7 @@ lib /DEF:"$(ProjectDir)Preferences_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Pla
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="sci_gateway\c\sci_archive_list.c" />
     <ClCompile Include="sci_gateway\c\sci_getURL.c" />
     <ClCompile Include="sci_gateway\c\sci_splitURL.c" />
     <ClCompile Include="sci_gateway\c\sci_tempname.c" />
@@ -241,6 +242,7 @@ lib /DEF:"$(ProjectDir)Preferences_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Pla
     <ClCompile Include="src\c\getrelativefilename.c" />
     <ClCompile Include="src\c\getshortpathname.c" />
     <ClCompile Include="sci_gateway\c\gw_fileio.c" />
+    <ClCompile Include="src\c\archive_list.c" />
     <ClCompile Include="src\c\isdir.c" />
     <ClCompile Include="src\c\isDrive.c" />
     <ClCompile Include="src\c\mclearerr.c" />
@@ -315,6 +317,8 @@ lib /DEF:"$(ProjectDir)Preferences_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Pla
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\addfile.h" />
+    <ClInclude Include="includes\archive_list.h" />
+    <ClInclude Include="src\c\archive_list.h" />
     <ClInclude Include="includes\createtempfilename.h" />
     <ClInclude Include="includes\deleteafile.h" />
     <ClInclude Include="includes\diary.h" />
@@ -407,4 +411,4 @@ lib /DEF:"$(ProjectDir)Preferences_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Pla
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index 56c15e1..261fa11 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,6 +24,9 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="src\c\archive_list.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="src\c\addfile.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="src\c\scanf_functions.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="sci_gateway\c\sci_archive_list.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="sci_gateway\c\sci_basename.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClInclude Include="includes\addfile.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="includes\archive_list.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="src\c\archive_list.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
     <ClInclude Include="src\c\basename.h">
       <Filter>Header Files</Filter>
     </ClInclude>
       <Filter>Libraries Dependencies\Imports</Filter>
     </None>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/scilab/modules/fileio/help/en_US/archiveList.xml b/scilab/modules/fileio/help/en_US/archiveList.xml
new file mode 100644 (file)
index 0000000..3426a38
--- /dev/null
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2015 - Kartik Gupta
+ * 
+ * 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
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="archiveList" xml:lang="en">
+    <refnamediv>
+        <refname>archiveList</refname>
+        <refpurpose>Lists the contents of an archive</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>x = archiveList(archive)</synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>archive</term>
+                <listitem>
+                    <para>a character string containing the absolute or relative path to the archive.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ierr</term>
+                <listitem>
+                    <para>error indicator, 0, if no error has occurred.</para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>
+            <code>x = archiveList(archive)</code> returns:
+        </para>
+        <variablelist>
+            <varlistentry>
+                <term>x</term>
+                <listitem>
+                    <para>The list containing the filenames in the archive</para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+     
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[ 
+x = archiveList("example.tar");
+y = archiveList("example.tar.gz");
+z = archiveList("example.tar.zip");
+ ]]></programlisting>
+    </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.6.0</revnumber>
+                <revremark>
+                    Function <literal>archiveList(archive)</literal> introduced
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
+     
+</refentry>
diff --git a/scilab/modules/fileio/includes/archive_list.h b/scilab/modules/fileio/includes/archive_list.h
new file mode 100644 (file)
index 0000000..dffcdea
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2015 - Kartik Gupta
+*
+* 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
+*
+*/
+/*--------------------------------------------------------------------------*/
+#ifndef __ARCHIVE_LIST_H__
+#define __ARCHIVE_LIST_H__
+
+#include "dynlib_fileio.h"
+
+/**
+* Returns a list of files in the archive
+* @param[filename] The absolute or relative path to the archive.
+* @param[size] The size of the list
+* @param[error] The error code for error detection
+* @return returns a pointer to a matrix containing the file names.
+*/
+
+FILEIO_IMPEXP char** archive_list(char *filename, int *size, int *error);
+
+
+#endif
+/*--------------------------------------------------------------------------*/
index 566cd38..dfe1069 100644 (file)
@@ -63,6 +63,8 @@ int sci_mputl(char *fname, unsigned long fname_len);
 int sci_tempname(char *fname, unsigned long fname_len);
 int sci_getURL(char *fname, unsigned long fname_len);
 int sci_splitURL(char *fname, unsigned long fname_len);
+int sci_archive_list(char *fname, unsigned long fname_len);
+
 /*--------------------------------------------------------------------------*/
 #endif /* __GW_FILEIO_H__ */
 /*--------------------------------------------------------------------------*/
index a9e57b1..c71eba8 100644 (file)
@@ -67,7 +67,8 @@ static gw_generic_table Tab[] =
     {sci_mputl, "mputl"},
     {sci_tempname, "tempname"},
     {sci_getURL, "getURL"},
-    {sci_splitURL, "splitURL"}
+    {sci_splitURL, "splitURL"},
+    {sci_archive_list,"archiveList"}
 };
 /*--------------------------------------------------------------------------*/
 int gw_fileio(void)
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_archive_list.c b/scilab/modules/fileio/sci_gateway/c/sci_archive_list.c
new file mode 100644 (file)
index 0000000..0e76014
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2015 - Kartik Gupta
+*
+* 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
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include <stdlib.h>
+#include <string.h>
+#include "gw_fileio.h"
+#include "api_scilab.h"
+#include "MALLOC.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "PATH_MAX.h"
+#include "archive_list.h"
+#include "freeArrayOfString.h"
+#include "expandPathVariable.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+/*--------------------------------------------------------------------------*/
+int sci_archive_list(char *fname, unsigned long fname_len)
+{
+    SciErr sciErr;
+    int *piAddressVarOne = NULL;
+    char **pStVarOne = NULL;
+    int mOne = 0, nOne = 0;
+    int mnOne = 0;
+
+    char **fileList = NULL;
+    int i = 0;
+    char *pathextended;
+    int rows, cols, error;
+
+    Rhs = Max(Rhs, 0);
+    CheckRhs(1, 1);
+    CheckLhs(0, 1);
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (!isStringType(pvApiCtx, piAddressVarOne))
+    {
+        if (isEmptyMatrix(pvApiCtx, piAddressVarOne))
+        {
+            createEmptyMatrix(pvApiCtx, Rhs + 1);
+            LhsVar(1) = Rhs + 1;
+            PutLhsVar()
+        }
+        else
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
+        }
+        return 0;
+    }
+    if (getAllocatedMatrixOfString(pvApiCtx, piAddressVarOne, &mOne, &nOne, &pStVarOne) != 0)
+    {
+        freeAllocatedMatrixOfString(mOne, nOne, pStVarOne);
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
+    cols = 1;
+    fileList = NULL;
+    pathextended = expandPathVariable(pStVarOne[0]);
+    fileList = (char**)(archive_list(pathextended,&rows,&error));
+    freeAllocatedMatrixOfString(mOne, nOne, pStVarOne);
+    if(error == 1)
+    {
+        Scierror(999, _("%s: Sorry the archive could not be opened\n"), fname);
+        return 0;
+    }
+    else if(error == 2)
+    {
+           Scierror(999, _("%s: Sorry the archive could not be closed.\n"), fname);
+           return 0;
+    }
+    CreateVarFromPtr(Rhs + 1, MATRIX_OF_STRING_DATATYPE, &rows, &cols, fileList);
+    LhsVar(1) = Rhs + 1;
+
+    PutLhsVar();
+    return 0;
+}
+/*--------------------------------------------------------------------------*/
+
+
index 58baec3..1e717e2 100644 (file)
@@ -81,4 +81,5 @@
     <PRIMITIVE gatewayId="34" primitiveId="46" primitiveName="tempname" />
     <PRIMITIVE gatewayId="34" primitiveId="47" primitiveName="getURL" />
     <PRIMITIVE gatewayId="34" primitiveId="48" primitiveName="splitURL" />
+    <PRIMITIVE gatewayId="34" primitiveId="49" primitiveName="archiveList" />
 </GATEWAY>
diff --git a/scilab/modules/fileio/src/c/archive_list.c b/scilab/modules/fileio/src/c/archive_list.c
new file mode 100644 (file)
index 0000000..bdae6d9
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2015 - Kartik Gupta
+ *
+ * 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
+ *
+ */
+
+#include<archive.h>
+#include<stdio.h>
+#include<stdlib.h>
+#include<archive_entry.h>
+#include<string.h>
+#include "MALLOC.h"
+
+char** archive_list(char *filename, int *size, int *error)
+{
+    struct archive *a;
+    struct archive_entry *entry;
+    int r;
+    a = archive_read_new();
+    archive_read_support_filter_all(a);
+    archive_read_support_format_all(a);
+    r = archive_read_open_filename(a, filename, 10240);    //Opening the archive to read the headers
+    char **file_list;
+
+
+    if (r != ARCHIVE_OK) //If the archive could not be opened
+    {
+        *error = 1;
+        return file_list;
+    }
+    *size = 0;
+
+
+    while (archive_read_next_header(a, &entry) == ARCHIVE_OK)
+    {   //Iterating over the archive header to get filenames
+        *size = *size + 1;
+        if((*size) == 1)
+        {
+            file_list = (char**)MALLOC(sizeof(char*)*(*size));
+        }
+        else
+        {
+            file_list = (char**)REALLOC(file_list,sizeof(char*)*(*size));
+        }
+        file_list[(*size)-1] = (char*)MALLOC(sizeof(char)*1024);
+        file_list[(*size)-1] = NULL;
+        file_list[(*size)-1] = strdup(archive_entry_pathname(entry));
+        archive_read_data_skip(a);
+    }
+
+
+    r = archive_read_free(a); 
+    if (r != ARCHIVE_OK) //If the archive struct could not be freed properly
+    {
+        *error = 2;
+        return file_list;
+    }
+
+
+    return file_list;
+}
diff --git a/scilab/modules/fileio/src/c/archive_list.h b/scilab/modules/fileio/src/c/archive_list.h
new file mode 100644 (file)
index 0000000..a279898
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2015 - Kartik Gupta
+*
+* 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
+*
+*/
+
+#ifndef __ARCHIVE_LIST_H__
+#define __ARCHIVE_LIST_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <archive.h>
+#include <archive_entry.h>
+
+char** archive_list(char *filename,int *size, int *error);
+
+#endif
diff --git a/scilab/modules/fileio/tests/unit_tests/archiveList.dia.ref b/scilab/modules/fileio/tests/unit_tests/archiveList.dia.ref
new file mode 100644 (file)
index 0000000..00a1544
--- /dev/null
@@ -0,0 +1,22 @@
+// ============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - DIGITEO - Kartik Gupta
+//
+//  This file is distributed under the same license as the Scilab package.
+// ============================================================================
+// <-- CLI SHELL MODE -->
+// ============================================================================
+// Unitary tests for archiveList function
+// ============================================================================
+files = archiveList("SCI/modules/fileio/tests/unit_tests/example.tar");
+if length(length(files)) <> 2 | files(1) <> "example1.txt" | files(2) <> "example2.txt" then bugmes();quit;end
+files = archiveList("SCI/modules/fileio/tests/unit_tests/example.tar.gz");
+if length(length(files)) <> 2 | files(1) <> "example1.txt" | files(2) <> "example2.txt" then bugmes();quit;end
+files = archiveList("SCI/modules/fileio/tests/unit_tests\example.tar.gz");
+if length(length(files)) <> 2 | files(1) <> "example1.txt" | files(2) <> "example2.txt" then bugmes();quit;end
+files = archiveList("SCI/modules/fileio/tests\unit_tests/example.tar.gz");
+if length(length(files)) <> 2 | files(1) <> "example1.txt" | files(2) <> "example2.txt" then bugmes();quit;end
+ierr = execstr("archiveList(SCI)","errcatch");
+if ierr <> 999 then bugmes();quit;end
+ierr = execstr("archiveList(SCI,1)","errcatch");
+if ierr <> 77 then bugmes();quit;end
diff --git a/scilab/modules/fileio/tests/unit_tests/archiveList.tst b/scilab/modules/fileio/tests/unit_tests/archiveList.tst
new file mode 100644 (file)
index 0000000..e6adef1
--- /dev/null
@@ -0,0 +1,30 @@
+// ============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - DIGITEO - Kartik Gupta
+//
+//  This file is distributed under the same license as the Scilab package.
+// ============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// ============================================================================
+// Unitary tests for archiveList function
+// ============================================================================
+
+files = archiveList("SCI/modules/fileio/tests/unit_tests/example.tar");
+if length(length(files)) <> 2 | files(1) <> "example1.txt" | files(2) <> "example2.txt" then pause,end
+
+files = archiveList("SCI/modules/fileio/tests/unit_tests/example.tar.gz");
+if length(length(files)) <> 2 | files(1) <> "example1.txt" | files(2) <> "example2.txt" then pause,end
+
+files = archiveList("SCI/modules/fileio/tests/unit_tests\example.tar.gz");
+if length(length(files)) <> 2 | files(1) <> "example1.txt" | files(2) <> "example2.txt" then pause,end
+
+files = archiveList("SCI/modules/fileio/tests\unit_tests/example.tar.gz");
+if length(length(files)) <> 2 | files(1) <> "example1.txt" | files(2) <> "example2.txt" then pause,end
+
+ierr = execstr("archiveList(SCI)","errcatch");
+if ierr <> 999 then pause,end
+
+ierr = execstr("archiveList(SCI,1)","errcatch");
+if ierr <> 77 then pause,end
diff --git a/scilab/modules/fileio/tests/unit_tests/example.tar b/scilab/modules/fileio/tests/unit_tests/example.tar
new file mode 100644 (file)
index 0000000..7071908
Binary files /dev/null and b/scilab/modules/fileio/tests/unit_tests/example.tar differ
diff --git a/scilab/modules/fileio/tests/unit_tests/example.tar.gz b/scilab/modules/fileio/tests/unit_tests/example.tar.gz
new file mode 100644 (file)
index 0000000..37597ce
Binary files /dev/null and b/scilab/modules/fileio/tests/unit_tests/example.tar.gz differ