archiveCompress added complete and tests updated. 33/16733/2
Kartik Gupta [Sat, 27 Jun 2015 10:57:25 +0000 (15:57 +0530)]
Change-Id: I431b0c3b33b422c6cb93396d004b26cb5faa44c4

19 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/archiveCompress.xml [new file with mode: 0644]
scilab/modules/fileio/includes/archive_compress.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_compress.c [new file with mode: 0644]
scilab/modules/fileio/sci_gateway/c/sci_archive_extract.c
scilab/modules/fileio/sci_gateway/fileio_gateway.xml
scilab/modules/fileio/src/c/archive_compress.c [new file with mode: 0644]
scilab/modules/fileio/src/c/archive_compress.h [new file with mode: 0644]
scilab/modules/fileio/tests/unit_tests/archiveCompress.dia.ref [new file with mode: 0644]
scilab/modules/fileio/tests/unit_tests/archiveCompress.tst [new file with mode: 0644]
scilab/modules/fileio/tests/unit_tests/archiveExtract.dia.ref
scilab/modules/fileio/tests/unit_tests/archiveExtract.tst
scilab/modules/fileio/tests/unit_tests/archiveList.dia.ref
scilab/modules/fileio/tests/unit_tests/archiveList.tst

index 2ce8437..012dbf7 100644 (file)
@@ -59,7 +59,8 @@ src/c/createtempfilename.c \
 src/c/dlManager.c \
 src/c/convert_tools.c \
 src/c/archive_list.c \
-src/c/archive_extract.c
+src/c/archive_extract.c \
+src/c/archive_compress.c
 
 GATEWAY_SOURCES = \
 sci_gateway/c/gw_fileio.c \
@@ -111,7 +112,8 @@ sci_gateway/c/sci_tempname.c \
 sci_gateway/c/sci_getURL.c \
 sci_gateway/c/sci_splitURL.c \
 sci_gateway/c/sci_archive_list.c \
-sci_gateway/c/sci_archive_extract.c
+sci_gateway/c/sci_archive_extract.c \
+sci_gateway/c/sci_archive_compress.c
 
 libscifileio_la_CPPFLAGS = -I$(srcdir)/includes/ \
                                -I$(srcdir)/src/c/ \
index 855bf48..7d5c927 100644 (file)
@@ -224,7 +224,8 @@ am__objects_1 = src/c/libscifileio_algo_la-FileExist.lo \
        src/c/libscifileio_algo_la-dlManager.lo \
        src/c/libscifileio_algo_la-convert_tools.lo \
        src/c/libscifileio_algo_la-archive_list.lo \
-       src/c/libscifileio_algo_la-archive_extract.lo
+       src/c/libscifileio_algo_la-archive_extract.lo \
+       src/c/libscifileio_algo_la-archive_compress.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@)
@@ -284,7 +285,8 @@ am__objects_2 = sci_gateway/c/libscifileio_la-gw_fileio.lo \
        sci_gateway/c/libscifileio_la-sci_getURL.lo \
        sci_gateway/c/libscifileio_la-sci_splitURL.lo \
        sci_gateway/c/libscifileio_la-sci_archive_list.lo \
-       sci_gateway/c/libscifileio_la-sci_archive_extract.lo
+       sci_gateway/c/libscifileio_la-sci_archive_extract.lo \
+       sci_gateway/c/libscifileio_la-sci_archive_compress.lo
 am_libscifileio_la_OBJECTS = $(am__objects_2)
 libscifileio_la_OBJECTS = $(am_libscifileio_la_OBJECTS)
 @MAINTAINER_MODE_FALSE@am_libscifileio_la_rpath =
@@ -687,7 +689,8 @@ src/c/createtempfilename.c \
 src/c/dlManager.c \
 src/c/convert_tools.c \
 src/c/archive_list.c \
-src/c/archive_extract.c
+src/c/archive_extract.c \
+src/c/archive_compress.c
 
 GATEWAY_SOURCES = \
 sci_gateway/c/gw_fileio.c \
@@ -739,7 +742,8 @@ sci_gateway/c/sci_tempname.c \
 sci_gateway/c/sci_getURL.c \
 sci_gateway/c/sci_splitURL.c \
 sci_gateway/c/sci_archive_list.c \
-sci_gateway/c/sci_archive_extract.c
+sci_gateway/c/sci_archive_extract.c \
+sci_gateway/c/sci_archive_compress.c
 
 libscifileio_la_CPPFLAGS = -I$(srcdir)/includes/ \
                                -I$(srcdir)/src/c/ \
@@ -1061,6 +1065,8 @@ src/c/libscifileio_algo_la-archive_list.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
 src/c/libscifileio_algo_la-archive_extract.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
+src/c/libscifileio_algo_la-archive_compress.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)
@@ -1220,6 +1226,9 @@ sci_gateway/c/libscifileio_la-sci_archive_list.lo:  \
 sci_gateway/c/libscifileio_la-sci_archive_extract.lo:  \
        sci_gateway/c/$(am__dirstamp) \
        sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/c/libscifileio_la-sci_archive_compress.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)
@@ -1235,6 +1244,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_compress.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_archive_extract.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@
@@ -1289,6 +1299,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_compress.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscifileio_algo_la-archive_extract.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@
@@ -1757,6 +1768,13 @@ src/c/libscifileio_algo_la-archive_extract.lo: src/c/archive_extract.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-archive_extract.lo `test -f 'src/c/archive_extract.c' || echo '$(srcdir)/'`src/c/archive_extract.c
 
+src/c/libscifileio_algo_la-archive_compress.lo: src/c/archive_compress.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_compress.lo -MD -MP -MF src/c/$(DEPDIR)/libscifileio_algo_la-archive_compress.Tpo -c -o src/c/libscifileio_algo_la-archive_compress.lo `test -f 'src/c/archive_compress.c' || echo '$(srcdir)/'`src/c/archive_compress.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscifileio_algo_la-archive_compress.Tpo src/c/$(DEPDIR)/libscifileio_algo_la-archive_compress.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/archive_compress.c' object='src/c/libscifileio_algo_la-archive_compress.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_compress.lo `test -f 'src/c/archive_compress.c' || echo '$(srcdir)/'`src/c/archive_compress.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
@@ -2107,6 +2125,13 @@ sci_gateway/c/libscifileio_la-sci_archive_extract.lo: sci_gateway/c/sci_archive_
 @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_extract.lo `test -f 'sci_gateway/c/sci_archive_extract.c' || echo '$(srcdir)/'`sci_gateway/c/sci_archive_extract.c
 
+sci_gateway/c/libscifileio_la-sci_archive_compress.lo: sci_gateway/c/sci_archive_compress.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_compress.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_archive_compress.Tpo -c -o sci_gateway/c/libscifileio_la-sci_archive_compress.lo `test -f 'sci_gateway/c/sci_archive_compress.c' || echo '$(srcdir)/'`sci_gateway/c/sci_archive_compress.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_archive_compress.Tpo sci_gateway/c/$(DEPDIR)/libscifileio_la-sci_archive_compress.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sci_gateway/c/sci_archive_compress.c' object='sci_gateway/c/libscifileio_la-sci_archive_compress.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_compress.lo `test -f 'sci_gateway/c/sci_archive_compress.c' || echo '$(srcdir)/'`sci_gateway/c/sci_archive_compress.c
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index 7083165..df9f5dd 100644 (file)
@@ -208,6 +208,7 @@ lib /DEF:"$(ProjectDir)Preferences_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Pla
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="sci_gateway\c\sci_archive_compress.c" />
     <ClCompile Include="sci_gateway\c\sci_archive_extract.c" />
     <ClCompile Include="sci_gateway\c\sci_archive_list.c" />
     <ClCompile Include="sci_gateway\c\sci_getURL.c" />
@@ -268,6 +269,9 @@ lib /DEF:"$(ProjectDir)Preferences_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Pla
     <ClCompile Include="src\c\readline.c" />
     <ClCompile Include="src\c\removedir.c" />
     <ClCompile Include="src\c\scanf_functions.c" />
+    <ClCompile Include="src\c\archive_compress.c" />
+    <ClCompile Include="src\c\archive_extract.c" />
+    <ClCompile Include="src\c\archive_list.c" />
     <ClCompile Include="sci_gateway\c\sci_basename.c" />
     <ClCompile Include="sci_gateway\c\sci_chdir.c" />
     <ClCompile Include="sci_gateway\c\sci_copyfile.c" />
@@ -320,8 +324,10 @@ lib /DEF:"$(ProjectDir)Preferences_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Pla
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\addfile.h" />
+    <ClInclude Include="includes\archive_compress.h" />
     <ClInclude Include="includes\archive_extract.h" />
     <ClInclude Include="includes\archive_list.h" />
+    <ClInclude Include="src\c\archive_compress.h" />
     <ClInclude Include="src\c\archive_extract.h" />
     <ClInclude Include="src\c\archive_list.h" />
     <ClInclude Include="includes\createtempfilename.h" />
index 5832c31..80750b6 100644 (file)
@@ -27,6 +27,9 @@
     <ClCompile Include="src\c\addfile.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\c\archive_compress.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="src\c\archive_extract.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_compress.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="sci_gateway\c\sci_archive_extract.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClInclude Include="includes\addfile.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="includes\archive_compress.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="src\c\archive_compress.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
     <ClInclude Include="includes\archive_extract.h">
       <Filter>Header Files</Filter>
     </ClInclude>
diff --git a/scilab/modules/fileio/help/en_US/archiveCompress.xml b/scilab/modules/fileio/help/en_US/archiveCompress.xml
new file mode 100644 (file)
index 0000000..594f98d
--- /dev/null
@@ -0,0 +1,79 @@
+<?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="archiveCompress" xml:lang="en">
+    <refnamediv>
+        <refname>archiveCompress</refname>
+        <refpurpose>Creates and archive of the formats tar, tar.gz, tar.bz2 or zip</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>x = archiveCompress(archive,[files],format)</synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>archive</term>
+                <listitem>
+                    <para>Absolute or relative path to an archive to be created</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>[files]</term>
+                <listitem>
+                    <para>A list of relative or absolute paths of the files to be included in the archive
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>Format</term>
+                <listitem>
+                    <para>The format argument.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>
+            <code>archiveCompress(archive,[files],format)</code> Creates the <varname>archive</varname>. The path can be absolute or relative. Returns 0 on success and -1 on failure.
+        </para>
+        <para>
+            <varname>[files]</varname> This list should contain the absolute or relative paths of all the files to be included in the archive.
+        </para>
+        <para>
+            <varname>format</varname> An empty string "" for .tar, "Z" for .zip, "y" or "j" for tar.bz2 and "z" for tar.gz .
+        </para>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+x = archiveExtract("example.tar",["file1","file2"],"")
+y = archiveExtract("example.tar.gz",["~/file1","file2"],"z")
+z = archiveExtract("example.zip",["file1","~/file2"],"Z")
+ ]]></programlisting>
+    </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.6.0</revnumber>
+                <revremark>
+                    Function <literal>archiveCompress(archive,[files],format)</literal> introduced
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/fileio/includes/archive_compress.h b/scilab/modules/fileio/includes/archive_compress.h
new file mode 100644 (file)
index 0000000..5c41e23
--- /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_COMPRESS_H__
+#define __ARCHIVE_COMPRESS_H__
+
+#include "dynlib_fileio.h"
+
+/**
+* Returns a list of files in the archive
+* @param[filename] The archive name
+* @param[file_list] Space seperated file list
+* @param[arg_list] The argument for the format of the archive
+* @return returns a 0 on success and -1 on failure
+*/
+
+FILEIO_IMPEXP int archive_compress(char *archive_name, char **file_list, int size, char *arg_list, int *error);
+
+
+#endif
+/*--------------------------------------------------------------------------*/
index 9f26af1..0e2bc54 100644 (file)
@@ -65,6 +65,7 @@ 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);
 int sci_archive_extract(char *fname, unsigned long fname_len);
+int sci_archive_compress(char *fname, unsigned long fname_len);
 /*--------------------------------------------------------------------------*/
 #endif /* __GW_FILEIO_H__ */
 /*--------------------------------------------------------------------------*/
index 4e7e521..8759ef5 100644 (file)
@@ -69,7 +69,8 @@ static gw_generic_table Tab[] =
     {sci_getURL, "getURL"},
     {sci_splitURL, "splitURL"},
     {sci_archive_list, "archiveList"},
-    {sci_archive_extract, "archiveExtract"}
+    {sci_archive_extract, "archiveExtract"},
+    {sci_archive_compress, "archiveCompress"}
 };
 /*--------------------------------------------------------------------------*/
 int gw_fileio(void)
diff --git a/scilab/modules/fileio/sci_gateway/c/sci_archive_compress.c b/scilab/modules/fileio/sci_gateway/c/sci_archive_compress.c
new file mode 100644 (file)
index 0000000..b389f3c
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+* 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 "freeArrayOfString.h"
+#include "expandPathVariable.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+#include <unistd.h>
+#include "isdir.h"
+#include "createdirectory.h"
+#include "scicurdir.h"
+#include "archive_compress.h"
+/*--------------------------------------------------------------------------*/
+int sci_archive_compress(char *fname, unsigned long fname_len)
+{
+    SciErr sciErr;
+    int *piAddressVarOne = NULL;
+    char *pStVarOne = NULL;
+    char *pStVarOneExpanded = NULL;
+
+    int *piAddressVarTwo = NULL;
+    char **pStVarTwo = NULL;
+    int m1 = 0;
+    int n1 = 0;
+    int i = 0;
+
+    int *piAddressVarThree = NULL;
+    char *pStVarThree = NULL;
+
+    char **file_list = NULL;
+    /* Check Input & Output parameters */
+    CheckRhs(3, 3);
+    CheckLhs(1, 2);
+    int result = 0;
+    int *error = 0;
+
+    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) == 0 || isScalar(pvApiCtx, piAddressVarOne) == 0)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+        return 0;
+    }
+
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (isDoubleType(pvApiCtx, piAddressVarTwo))
+    {
+        if (isEmptyMatrix(pvApiCtx, piAddressVarTwo))
+        {
+            if (createEmptyMatrix(pvApiCtx, Rhs + 2))
+            {
+                Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                return 0;
+            }
+        }
+        else
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: String array expected.\n"), fname, 1);
+            return 0;
+        }
+
+        LhsVar(1) = Rhs + 1;
+        PutLhsVar();
+        return 0;
+    }
+
+    if (isStringType(pvApiCtx, piAddressVarTwo) == 0)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: String array expected.\n"), fname, 2);
+        return 0;
+    }
+
+    if (getAllocatedMatrixOfString(pvApiCtx, piAddressVarTwo, &m1, &n1, &pStVarTwo))
+    {
+        freeAllocatedMatrixOfString(m1, n1, pStVarTwo);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+        return 0;
+    }
+
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddressVarThree);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
+        return 0;
+    }
+
+    if (isStringType(pvApiCtx, piAddressVarThree) == 0 || isScalar(pvApiCtx, piAddressVarThree) == 0)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 3);
+        return 0;
+    }
+
+
+    if (getAllocatedSingleString(pvApiCtx, piAddressVarOne, &pStVarOne))
+    {
+        if (pStVarOne)
+        {
+            freeAllocatedSingleWideString(pStVarOne);
+        }
+
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 0;
+    }
+
+    if (getAllocatedSingleString(pvApiCtx, piAddressVarThree, &pStVarThree))
+    {
+        if (pStVarThree)
+        {
+            freeAllocatedSingleWideString(pStVarThree);
+        }
+
+        freeAllocatedSingleString(pStVarOne);
+        freeAllocatedSingleString(pStVarTwo);
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 0;
+    }
+
+
+    int size = 0;
+    while (i < (m1 * n1))
+    {
+        size++;
+        if (file_list != NULL)
+        {
+            file_list = (char**)REALLOC(file_list, sizeof(char*) * (size));
+        }
+        else
+        {
+            file_list = (char**)MALLOC(sizeof(char*) * (size));
+        }
+        file_list[size - 1] = (char*)MALLOC(sizeof(char) * 512);
+        strcpy(file_list[size - 1], expandPathVariable(pStVarTwo[i]));
+        i++;
+    }
+
+
+    i = 0;
+    if (strlen(pStVarThree) > 2)
+    {
+        Scierror(999, _("%s: Sorry unrecognised format type.\n"), fname);
+        return 0;
+    }
+    while (i < strlen(pStVarThree))
+    {
+        if (pStVarThree[i] != 'Z' && pStVarThree[i] != 'j' && pStVarThree[i] != 'y' && pStVarThree[i] != 'z')
+        {
+            Scierror(999, _("%s: Sorry unrecognised format type.\n"), fname);
+            return 0;
+        }
+        i++;
+    }
+    result = archive_compress(pStVarOne, file_list, size, pStVarThree, &error);
+
+
+    if (error == 1)
+    {
+        Scierror(999, _("%s: Sorry the file could not be opened.\n"), fname);
+        return 0;
+    }
+    if (error == 2)
+    {
+        Scierror(999, _("%s: Sorry the file header could not be read\n"), fname);
+        return 0;
+    }
+    if (error == 3)
+    {
+        Scierror(999, _("%s: Sorry the file header could not be written.\n"), fname);
+        return 0;
+    }
+
+    freeAllocatedSingleString(pStVarOne);
+    freeAllocatedSingleString(pStVarTwo);
+    createScalarInteger32(pvApiCtx, Rhs + 1, result);
+    LhsVar(1) = Rhs + 1;
+    PutLhsVar();
+    return 0;
+
+}
+/*--------------------------------------------------------------------------*/
+
+
index 1a5fce7..498b5af 100644 (file)
@@ -146,15 +146,15 @@ int sci_archive_extract(char *fname, unsigned long fname_len)
         }
         error = 0;
 #ifdef _WIN32
-        if (pathextended[1] != ':' || pathextended[2] != '\')       //Checking if the path is absolute or relative for windows
-                {
-                strcat(pathextended_temp,current_directory);
-                strcat(pathextended_temp,'\');
-                strcat(pathextended_temp,pathextended);
-                pathextended = pathextended_temp;
-            }
+        if (pathextended[1] != ':' || pathextended[2] != 92)       //Checking if the path is absolute or relative for windows
+        {
+            strcat(pathextended_temp, current_directory);
+            strcat(pathextended_temp, '\');
+                   strcat(pathextended_temp,pathextended);
+                   pathextended = pathextended_temp;
+               }
 #else
-        if(!(pathextended[0] == ' / '))          //Checking if the path is absolute or relative for linux
+        if(!(pathextended[0] == 47))          //Checking if the path is absolute or relative for linux
         {
             strcat(pathextended_temp,current_directory);
             strcat(pathextended_temp,"/");
@@ -162,79 +162,79 @@ int sci_archive_extract(char *fname, unsigned long fname_len)
             pathextended = pathextended_temp;
         }
 #endif
-                pathextended_destination = expandPathVariable(pStVarThree[0]);
-                if(!isdir(pathextended_destination))
-                {
-                if(!createdirectory(pathextended_destination))
-                {
-                Scierror(999, _("%s: Sorry the destinations folder could not be created.\n"), fname);
-                return 0;
-            }
-            }
-                if(chdir(pathextended_destination)!=0)
-                {
-                Scierror(999, _("%s: Sorry the destination folder could not be opened.\n"), fname);
-                return 0;
-            }
+                   pathextended_destination = expandPathVariable(pStVarThree[0]);
+                   if(!isdir(pathextended_destination))
+               {
+                   if(!createdirectory(pathextended_destination))
+               {
+                   Scierror(999, _("%s: Sorry the destinations folder could not be created.\n"), fname);
+                   return 0;
+               }
+               }
+                   if(chdir(pathextended_destination)!=0)
+               {
+                   Scierror(999, _("%s: Sorry the destination folder could not be opened.\n"), fname);
+                   return 0;
+               }
 
-            }
-                if(perm_flag == FALSE)
-                {
-                result = archive_extract(pathextended,0,&error);
-            }
-                else if(perm_flag == TRUE)
-                {
-                result = archive_extract(pathextended,1,&error);
-            }
-                if(error == 1)
-                {
-                Scierror(999, _("%s: Sorry the archive could not be opened.\n"), fname);
-                return 0;
-            }
-                if(error == 2)
-                {
-                Scierror(999, _("%s: Sorry the archive header could not be read.\n"), fname);
-                return 0;
-            }
-                if(error == 3)
-                {
-                Scierror(999, _("%s: Sorry the archive header could not be written.\n"), fname);
-                return 0;
-            }
-                if(error == 4)
-                {
-                Scierror(999, _("%s: Sorry the file data could not be read.\n"), fname);
-                return 0;
-            }
-                if(error == 5)
-                {
-                Scierror(999, _("%s: Sorry the file data could not be written.\n"), fname);
-                return 0;
-            }
-                if(error == 6)
-                {
-                Scierror(999, _("%s: Sorry the archive header could not be closed.\n"), fname);
-                return 0;
-            }
+               }
+                   if(perm_flag == FALSE)
+               {
+                   result = archive_extract(pathextended,0,&error);
+               }
+                   else if(perm_flag == TRUE)
+               {
+                   result = archive_extract(pathextended,1,&error);
+               }
+                   if(error == 1)
+               {
+                   Scierror(999, _("%s: Sorry the archive could not be opened.\n"), fname);
+                   return 0;
+               }
+                   if(error == 2)
+               {
+                   Scierror(999, _("%s: Sorry the archive header could not be read.\n"), fname);
+                   return 0;
+               }
+                   if(error == 3)
+               {
+                   Scierror(999, _("%s: Sorry the archive header could not be written.\n"), fname);
+                   return 0;
+               }
+                   if(error == 4)
+               {
+                   Scierror(999, _("%s: Sorry the file data could not be read.\n"), fname);
+                   return 0;
+               }
+                   if(error == 5)
+               {
+                   Scierror(999, _("%s: Sorry the file data could not be written.\n"), fname);
+                   return 0;
+               }
+                   if(error == 6)
+               {
+                   Scierror(999, _("%s: Sorry the archive header could not be closed.\n"), fname);
+                   return 0;
+               }
 
 
-                if(pStVarThree!=NULL)
-                {
-                if(chdir(current_directory)!=0)
-                {
-                Scierror(999, _("%s: Sorry could not return to the current directory.\n"), fname);
-                return 0;
-            }
-                freeAllocatedMatrixOfString(m1, n1, pStVarThree);
-            }
+                   if(pStVarThree!=NULL)
+               {
+                   if(chdir(current_directory)!=0)
+               {
+                   Scierror(999, _("%s: Sorry could not return to the current directory.\n"), fname);
+                   return 0;
+               }
+                   freeAllocatedMatrixOfString(m1, n1, pStVarThree);
+               }
 
-                freeAllocatedMatrixOfString(m1, n1, pStVarOne);
-                createScalarInteger32(pvApiCtx, Rhs + 1, result);
-                LhsVar(1) = Rhs + 1;
-                PutLhsVar();
-                return 0;
+                   freeAllocatedMatrixOfString(m1, n1, pStVarOne);
+                   createScalarInteger32(pvApiCtx, Rhs + 1, result);
+                   LhsVar(1) = Rhs + 1;
+                   PutLhsVar();
+                   return 0;
 
-            }
-                /*--------------------------------------------------------------------------*/
+               }
+                   /*--------------------------------------------------------------------------*/
 
 
index af16455..2182ec0 100644 (file)
@@ -83,4 +83,5 @@
     <PRIMITIVE gatewayId="34" primitiveId="48" primitiveName="splitURL" />
     <PRIMITIVE gatewayId="34" primitiveId="49" primitiveName="archiveList" />
     <PRIMITIVE gatewayId="34" primitiveId="50" primitiveName="archiveExtract" />
+    <PRIMITIVE gatewayId="34" primitiveId="51" primitiveName="archiveCompress" />
 </GATEWAY>
diff --git a/scilab/modules/fileio/src/c/archive_compress.c b/scilab/modules/fileio/src/c/archive_compress.c
new file mode 100644 (file)
index 0000000..42306bd
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+* 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<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include <archive.h>
+#include <archive_entry.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+int archive_compress(char *archive_name, char **file_list, int size, char *arg_list, int *error)
+{
+    int i = 0;
+    int j = strlen(arg_list);
+    i = 0;
+    int bzip2 = 0, gzip = 0, zip = 0;
+    while (i < (j - 1))
+    {
+        if (arg_list[i] == 'j' || arg_list[i] == 'y')
+        {
+            bzip2 = 1;
+        }
+        else if (arg_list[i] == 'Z')
+        {
+            zip = 1;
+        }
+        else if (arg_list[i] == 'z')
+        {
+            gzip = 1;
+        }
+        i++;
+    }
+    static char buff[16384];
+    struct archive *a;
+    struct archive *disk;
+    struct archive_entry *entry;
+    ssize_t len;
+    int fd;
+
+    a = archive_write_new();
+    if (bzip2 == 1)
+    {
+        archive_write_add_filter_bzip2(a);
+    }
+    else if (gzip == 1)
+    {
+        archive_write_add_filter_gzip(a);
+    }
+    else if (zip == 1)
+    {
+        archive_write_add_filter_compress(a);
+    }
+    else
+    {
+        archive_write_add_filter_none(a);
+    }
+
+    archive_write_set_format_ustar(a);
+    archive_write_open_filename(a, archive_name);
+    disk = archive_read_disk_new();
+    archive_read_disk_set_standard_lookup(disk);
+    i = 0;
+    while (i < size)
+    {
+        struct archive *disk = archive_read_disk_new();
+        int r;
+        r = archive_read_disk_open(disk, file_list[i]);
+        if (r != ARCHIVE_OK)
+        {
+            *error = 1;
+            return -1;
+        }
+        while (1)
+        {
+
+            entry = archive_entry_new();
+            r = archive_read_next_header2(disk, entry);
+            if (r == ARCHIVE_EOF)
+            {
+                break;
+            }
+            if (r != ARCHIVE_OK)
+            {
+                *error = 2;
+                return -1;
+            }
+            archive_read_disk_descend(disk);
+            char pathname[1024];
+            strcpy(pathname, archive_entry_pathname(entry));
+#ifdef _WIN32
+            if (pathname[1] == ":" && pathname[2] == 92)
+            {
+                int l = 0;
+                while (l < (strlen(archive_entry_pathname(entry)) - 2))
+                {
+                    pathname[l] = pathname[l + 3];
+                    l++;
+                }
+            }
+#else
+            if (pathname[0] == 47)
+            {
+                int l = 0;
+                while (l < (strlen(archive_entry_pathname(entry))))
+                {
+                    pathname[l] = pathname[l + 1];
+                    l++;
+                }
+            }
+#endif
+            archive_entry_set_pathname(entry, pathname);
+            r = archive_write_header(a, entry);
+            if (r < ARCHIVE_OK)
+            {
+                *error = 3;
+                return -1;
+            }
+            if (r == ARCHIVE_FATAL)
+            {
+                *error = 3;
+                return -1;
+            }
+            if (r > ARCHIVE_FAILED)
+            {
+                fd = open(archive_entry_sourcepath(entry), O_RDONLY);
+                len = read(fd, buff, sizeof(buff));
+                while (len > 0)
+                {
+                    archive_write_data(a, buff, len);
+                    len = read(fd, buff, sizeof(buff));
+                }
+                close(fd);
+            }
+            archive_entry_free(entry);
+        }
+        archive_read_close(disk);
+        archive_read_free(disk);
+        i++;
+    }
+    archive_write_close(a);
+    archive_write_free(a);
+
+
+    return 0;
+
+
+}
diff --git a/scilab/modules/fileio/src/c/archive_compress.h b/scilab/modules/fileio/src/c/archive_compress.h
new file mode 100644 (file)
index 0000000..3e89790
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+* 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_COMPRESS_H__
+#define __ARCHIVE_COMPRESS_H__
+
+#include<sys/types.h>
+#include<sys/stat.h>
+#include<archive.h>
+#include<archive_entry.h>
+#include<fcntl.h>
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include<unistd.h>
+
+int archive_compress(char *archive_name, char **file_list, int size, char *arg_list, int *error);
+
+#endif
diff --git a/scilab/modules/fileio/tests/unit_tests/archiveCompress.dia.ref b/scilab/modules/fileio/tests/unit_tests/archiveCompress.dia.ref
new file mode 100644 (file)
index 0000000..7941241
--- /dev/null
@@ -0,0 +1,46 @@
+// ============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Kartik Gupta
+//
+//  This file is distributed under the same license as the Scilab package.
+// ============================================================================
+// <-- CLI SHELL MODE -->
+// ============================================================================
+// Unitary tests for archiveCompress function
+// ============================================================================
+createdir("archiveCompress1");
+createdir("archiveCompress2");
+x = archiveCompress('example.tar',["archiveCompress1","archiveCompress2"],"");
+assert_checkequal(x,int32(0));
+assert_checktrue(isfile("example.tar"));
+files = archiveList("example.tar");
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"archiveCompress1/");
+assert_checkequal(files(2),"archiveCompress2/");
+deletefile("example.tar");
+x = archiveCompress('example.zip',["archiveCompress1","archiveCompress2"],"Z");
+assert_checkequal(x,int32(0));
+assert_checktrue(isfile("example.zip"));
+files = archiveList("example.zip");
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"archiveCompress1/");
+assert_checkequal(files(2),"archiveCompress2/");
+deletefile("example.zip");
+x = archiveCompress('example.tar.bz2',["archiveCompress1","archiveCompress2"],"y");
+assert_checkequal(x,int32(0));
+assert_checktrue(isfile("example.tar.bz2"));
+files = archiveList("example.tar.bz2");
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"archiveCompress1/");
+assert_checkequal(files(2),"archiveCompress2/");
+deletefile("example.tar.bz2");
+x = archiveCompress('example.tar.gz',["archiveCompress1","archiveCompress2"],"z");
+assert_checkequal(x,int32(0));
+assert_checktrue(isfile("example.tar.gz"));
+files = archiveList("example.tar.gz");
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"archiveCompress1/");
+assert_checkequal(files(2),"archiveCompress2/");
+deletefile("example.tar.gz");
+rmdir("archiveCompress1");
+rmdir("archiveCompress2");
diff --git a/scilab/modules/fileio/tests/unit_tests/archiveCompress.tst b/scilab/modules/fileio/tests/unit_tests/archiveCompress.tst
new file mode 100644 (file)
index 0000000..f93205a
--- /dev/null
@@ -0,0 +1,56 @@
+// ============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Kartik Gupta
+//
+//  This file is distributed under the same license as the Scilab package.
+// ============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// ============================================================================
+// Unitary tests for archiveCompress function
+// ============================================================================
+
+createdir("archiveCompress1");
+createdir("archiveCompress2");
+
+x = archiveCompress('example.tar',["archiveCompress1","archiveCompress2"],"");
+assert_checkequal(x,int32(0));
+assert_checktrue(isfile("example.tar"));
+files = archiveList("example.tar");
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"archiveCompress1/");
+assert_checkequal(files(2),"archiveCompress2/");
+deletefile("example.tar");
+
+x = archiveCompress('example.zip',["archiveCompress1","archiveCompress2"],"Z");
+assert_checkequal(x,int32(0));
+assert_checktrue(isfile("example.zip"));
+files = archiveList("example.zip");
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"archiveCompress1/");
+assert_checkequal(files(2),"archiveCompress2/");
+deletefile("example.zip");
+
+x = archiveCompress('example.tar.bz2',["archiveCompress1","archiveCompress2"],"y");
+assert_checkequal(x,int32(0));
+assert_checktrue(isfile("example.tar.bz2"));
+files = archiveList("example.tar.bz2");
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"archiveCompress1/");
+assert_checkequal(files(2),"archiveCompress2/");
+deletefile("example.tar.bz2");
+
+x = archiveCompress('example.tar.gz',["archiveCompress1","archiveCompress2"],"z");
+assert_checkequal(x,int32(0));
+assert_checktrue(isfile("example.tar.gz"));
+files = archiveList("example.tar.gz");
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"archiveCompress1/");
+assert_checkequal(files(2),"archiveCompress2/");
+deletefile("example.tar.gz");
+
+rmdir("archiveCompress1");
+rmdir("archiveCompress2");
+
+
index 2a1cc75..983cf48 100644 (file)
@@ -9,17 +9,20 @@
 // Unitary tests for archiveExtract function
 // ============================================================================
 x = archiveExtract("SCI/modules/fileio/tests/unit_tests/example.tar");
-if (~isfile("example1.txt") | ~isfile("example2.txt"))  then bugmes();quit;end
+assert_checktrue(isfile("example1.txt"));
+assert_checktrue(isfile("example2.txt"));
 deletefile("example1.txt");
 deletefile("example2.txt");
 x = archiveExtract("SCI/modules/fileio/tests/unit_tests/example.tar",%f);
-if (~isfile("example1.txt") | ~isfile("example2.txt"))  then bugmes();quit;end
+assert_checktrue(isfile("example1.txt"));
+assert_checktrue(isfile("example2.txt"));
 deletefile("example1.txt");
 deletefile("example2.txt");
 x = archiveExtract("SCI/modules/fileio/tests/unit_tests/example.tar",%t,"archiveExtract");
-if (~isfile("archiveExtract/example1.txt") | ~isfile("archiveExtract/example2.txt"))  then bugmes();quit;end
+assert_checktrue(isfile("archiveExtract/example1.txt"));
+assert_checktrue(isfile("archiveExtract/example2.txt"));
 removedir("archiveExtract");
 ierr = execstr("archiveExtract(SCI)","errcatch");
-if ierr <> 999 then bugmes();quit;end
+assert_checkequal(ierr,999);
 ierr = execstr("archiveExtract(SCI,1)","errcatch");
-if ierr <> 999 then bugmes();quit;end
+assert_checkequal(ierr,999);
index f4f8ebe..d635ac6 100644 (file)
 // ============================================================================
 
 x = archiveExtract("SCI/modules/fileio/tests/unit_tests/example.tar");
-if (~isfile("example1.txt") | ~isfile("example2.txt"))  then pause,end
-
+assert_checktrue(isfile("example1.txt"));
+assert_checktrue(isfile("example2.txt"));
 deletefile("example1.txt");
 deletefile("example2.txt");
 
 x = archiveExtract("SCI/modules/fileio/tests/unit_tests/example.tar",%f);
-if (~isfile("example1.txt") | ~isfile("example2.txt"))  then pause,end
-
+assert_checktrue(isfile("example1.txt"));
+assert_checktrue(isfile("example2.txt"));
 deletefile("example1.txt");
 deletefile("example2.txt");
 
 x = archiveExtract("SCI/modules/fileio/tests/unit_tests/example.tar",%t,"archiveExtract");
-if (~isfile("archiveExtract/example1.txt") | ~isfile("archiveExtract/example2.txt"))  then pause,end
-
+assert_checktrue(isfile("archiveExtract/example1.txt"));
+assert_checktrue(isfile("archiveExtract/example2.txt"));
 removedir("archiveExtract");
 
 ierr = execstr("archiveExtract(SCI)","errcatch");
-if ierr <> 999 then pause,end
+assert_checkequal(ierr,999);
 
 ierr = execstr("archiveExtract(SCI,1)","errcatch");
-if ierr <> 999 then pause,end
+assert_checkequal(ierr,999);
 
index 00a1544..abc5da5 100644 (file)
@@ -9,14 +9,22 @@
 // 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
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"example1.txt");
+assert_checkequal(files(2),"example2.txt");
 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
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"example1.txt");
+assert_checkequal(files(2),"example2.txt");
 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
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"example1.txt");
+assert_checkequal(files(2),"example2.txt");
 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
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"example1.txt");
+assert_checkequal(files(2),"example2.txt");
 ierr = execstr("archiveList(SCI)","errcatch");
-if ierr <> 999 then bugmes();quit;end
+assert_checkequal(ierr,999);
 ierr = execstr("archiveList(SCI,1)","errcatch");
-if ierr <> 77 then bugmes();quit;end
+assert_checkequal(ierr,77);
index e6adef1..bee2ef0 100644 (file)
 // ============================================================================
 
 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
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"example1.txt");
+assert_checkequal(files(2),"example2.txt");
 
 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
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"example1.txt");
+assert_checkequal(files(2),"example2.txt");
 
 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
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"example1.txt");
+assert_checkequal(files(2),"example2.txt");
 
 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
+assert_checkequal(length(length(files)),2);
+assert_checkequal(files(1),"example1.txt");
+assert_checkequal(files(2),"example2.txt");
 
 ierr = execstr("archiveList(SCI)","errcatch");
-if ierr <> 999 then pause,end
+assert_checkequal(ierr,999);
 
 ierr = execstr("archiveList(SCI,1)","errcatch");
-if ierr <> 77 then pause,end
+assert_checkequal(ierr,77);