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 \
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/ \
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@)
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 =
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 \
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/ \
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)
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)
-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@
@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@
@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
@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
-<?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">
</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" />
<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" />
</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" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
-<?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">
</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>
--- /dev/null
+<?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>
--- /dev/null
+/*
+* 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
+/*--------------------------------------------------------------------------*/
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__ */
/*--------------------------------------------------------------------------*/
{sci_mputl, "mputl"},
{sci_tempname, "tempname"},
{sci_getURL, "getURL"},
- {sci_splitURL, "splitURL"}
+ {sci_splitURL, "splitURL"},
+ {sci_archive_list,"archiveList"}
};
/*--------------------------------------------------------------------------*/
int gw_fileio(void)
--- /dev/null
+/*
+* 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;
+}
+/*--------------------------------------------------------------------------*/
+
+
<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>
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+* 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
--- /dev/null
+// ============================================================================
+// 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
--- /dev/null
+// ============================================================================
+// 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