mn8 Language Reference | Index    

Zip

SUMMARY: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

This concept allow to read and write the standard ZIP file.
This concept allow to add, remove, extract and view files form ZIP archive.

Usage

List files form specified ZIP archive.

            $zFile = Zip.create( "ZipName" )
            print $zFile.list

Add files and string to ZIP archive.

            $zFile = Zip.create("ZipName")
            $zFile.add("filePath")
            $zFile.add("text", "asPath")

View contents of files form ZIP archive.

            $zFile = Zip.create("ZipName")
            each $file in $zFile.list do [
                print $file
                print "-------------------------------------------------------------"
                print $zFile.view( $file )
                print "-------------------------------------------------------------"]

Extract all files in specified directory form ZIP archive.

            $zFile = Zip.create("ZipName")
            $zFile.extractAll("dirName")

Version: 0.1
Authors:Szabo Csaba ()
Location:
Inherits: Concept

Constructor List

create (String $path)
top

Method List

add (String $path)
add (String $content, String $path)
Seriesdelete (String $path)
extract (String $dir, String $path)
extractAll (String $dir)
Serieslist
Stringview (String $path)
top
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI

Detailed Constructor Info

create (String $path)
Parameters:
$path : The path to the location where the file will be created with the archive name.
Exceptions:
IOException :
(Error)
If unable to open the zip file.

Creates a new tar archive file with the specified path.

top

Detailed Method Info

add (String $path)
Parameters:
$path :The path to the file which will be added.
Returns:
Exceptions:
pathNotFoundException :
(Error)
If the path not found.
addtoZipFailed :
(Warning)
If can not add the file to zip archive.
IOException :
(Error)
If can not open the zip archive.

Adds the specified file to this archive.

                $zFile = Zip.create( "test.zip" )                                                                                 
                
                $zFile.add( "/devel/spacemapper/mn8/src/main/org/media/naming/" )                                                 
                
                print $zFile.list
                -- the result is --
                /devel/spacemapper/mn8/src/main/org/media/naming/MemoryContextTest.java
                /devel/spacemapper/mn8/src/main/org/media/naming/MemoryContextFactory.java
                /devel/spacemapper/mn8/src/main/org/media/naming/CVS/Repository
                /devel/spacemapper/mn8/src/main/org/media/naming/package.html
                /devel/spacemapper/mn8/src/main/org/media/naming/ReferenceRefAddr.java
                /devel/spacemapper/mn8/src/main/org/media/naming/CVS/Entries
                /devel/spacemapper/mn8/src/main/org/media/naming/MemoryBinding.java
                /devel/spacemapper/mn8/src/main/org/media/naming/MemoryContext.java
                /devel/spacemapper/mn8/src/main/org/media/naming/CVS/Root
            

top
add (String $content, String $path)
Parameters:
$content :The content of the file specified in the $path.
$path :The path to the file in the archive.
Returns:
Exceptions:
entryExistsException :
(Warning)
If can not add the file to zip archive.
IOException :
(Error)
If can not open the zip archive.

Adds a new file to this archive with the name specified in the $path and with the given $content.

                $zFile = Zip.create( "test.zip" )                                                                                 
                
                $zFile.add("This is a test", "text.txt")                                                                          
                $zFile.add("This is another test", "text1.txt")                                                                   
                
                print $zFile.list
                -- the result is --
                text.txt
                text1.txt  
            

top
delete (String $path)
Parameters:
$path :The path to the file in this archive which will be deleted.
Returns: Series
Exceptions:
pathNotFoundException :
(Error)
If can not open the zip archive.
IOException :
(Error)
If can not remove entry form zip archive.

Deletes the specified file from this archive.

                $zFile = Zip.create( "test.zip" )                                                                                 
                $zFile.add("This is a test", "text.txt")
                $zFile.add("This is another test", "text1.txt")
                
                $zFile.delete("text1.txt")
                
                print $zFile.list
                -- the result is --
                text.txt
            

top
extract (String $dir, String $path)
Parameters:
$dir : The path to the directory in which will be extracted the specified file.
$path : The path to the file in this archive which will be extracted.
Returns:
Exceptions:
pathNotFoundException :
(Error)
If can not open the zip archive.
IOException :
(Error)
If can not read the zip archive.

Extracts the specified file from this archive in the given directory.

                $zFile = Zip.create( "test.zip" )                                                                                 
                $zFile.add("This is a test", "text.txt")
                $zFile.add("This is another test", "text1.txt")
               
                print $zFile.extract("/temp/", "text.txt")
               
                -- the result is --
                Extract 'text.txt' file from archive.
            

top
extractAll (String $dir)
Parameters:
$dir : The path to the directory in which will be extracted this archive.
Returns:
Exceptions:
pathNotFoundException :
(Error)
If can not open the zip archive.
IOException :
(Error)
If can not read the zip archive.

Extracts all files from this archive in the specified directory.

                $zFile = Zip.create( "test.zip" )                                                                                 
                $zFile.add("This is a test", "text.txt")
                $zFile.add("This is another test", "text1.txt")
               
                print $zFile.extractAll("/temp/")
               
                -- the result is --
                Extract all files from archive.
            

top
list
Returns: Series

Returns a series which contains all files name in this archive.

                $zFile = Zip.create( "test.zip" )                                                                                 
                $zFile.add("This is a test", "text.txt")
                $zFile.add("This is another test", "text1.txt")
                
                print $zFile.list

                -- the result is --
                text.txt
                text1.txt
            

top
view (String $path)
Parameters:
$path :The path in this archive to the file.
Returns: String
Exceptions:
pathNotFoundException :
(Error)
If the specified path not found in zip archive.
IOException :
(Error)
If unable to read zip archive.

Returns the file content specified by the $path.

                $zFile = Zip.create( "test.zip" )                                                                                 
                $zFile.add("This is a test", "text.txt")
                $zFile.add("This is another test", "text1.txt")
                
                print $zFile.wiew("text.txt")

                -- the result is --
                This is a test
            

top