changeset 2635:95951526b7b2 octave-forge

Initial commit into CVS.
author sis-sou
date Mon, 09 Oct 2006 12:23:09 +0000
parents 9bd7ad32f2a7
children d425be1bdc29
files main/miscellaneous/inst/unzip.m main/miscellaneous/inst/zip.m
diffstat 2 files changed, 68 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/miscellaneous/inst/unzip.m	Mon Oct 09 12:23:09 2006 +0000
@@ -0,0 +1,32 @@
+function unzip(zipfile)
+	
+  if (nargin == 1)
+
+
+    if (ischar (zipfile))
+
+      cmd = sprintf ("unzip %s ", zipfile);
+
+      [status, output] = system (cmd);
+
+      if (status == 0)
+	if (nargout > 0)
+	  if (output(end) == "\n")
+	    output(end) = [];
+	  endif
+          entries = cellstr (split (output, "\n"));
+	  entries = entries';
+	endif
+      else
+	error ("unzip: unzip exited with status = %d", status);
+      endif
+    
+    else
+      error ("unzip: expecting an argument to be character strings");
+    endif
+
+  else
+		usage(" unzip(zipfiles)");
+  endif
+
+endfunction
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/miscellaneous/inst/zip.m	Mon Oct 09 12:23:09 2006 +0000
@@ -0,0 +1,36 @@
+function zip(zipfile, files)
+	
+  if (nargin == 2)
+
+    if (ischar (files))
+      files = cellstr (files);
+    endif
+
+    if (ischar (zipfile) && iscellstr (files))
+
+      cmd = sprintf ("zip %s %s", zipfile,
+		     sprintf (" %s", files{:}));
+
+      [status, output] = system (cmd);
+
+      if (status == 0)
+	if (nargout > 0)
+	  if (output(end) == "\n")
+	    output(end) = [];
+	  endif
+          entries = cellstr (split (output, "\n"));
+	  entries = entries';
+	endif
+      else
+	error ("zip: zip exited with status = %d", status);
+      endif
+    
+    else
+      error ("zip: expecting all arguments to be character strings");
+    endif
+
+  else
+		usage(" zip(zipfiles,files)");
+  endif
+
+endfunction
\ No newline at end of file