mn8 Language Reference | Index    

Tar

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 traditional UNIX tar file.
It currently supports creating, listing, removing and extracting from archives. It also supports GZIP - ed archives.

Usage

Create specified not compressed tar archive and extract all files from achive in specified directory

            $tar = Tar.create("tarName", false)
            $tar.extractAll("dirName")

Add files and string to tar archive.

            $tFile = Tar.create("TarName")
            $tFile.add("filePath")
            $tFile.add("text", "asPath")

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

Constructor List

create (String $path, Logical $compress)
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, Logical $compress)
Parameters:
$path :

The path to the location where the file will be created with the archive name.

$compress :Determines if the tar file will be compressed or not.

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:
IOException :
(Error)
If unable to open tar archive.
IOException :
(Warning)
If could not add file to tar archive.
pathNotFoundException :
(Error)
If the specified directory or file not exists.

Adds the specified file to this archive.

                $tarFile = Tar.create( "test.tgz", true )                                                                                 
                
                $tarFile.add( "/devel/spacemapper/mn8/src/main/org/media/naming/" )                                                 
                
                print $tarFile.list
                -- the result is --
                devel/spacemapper/mn8/src/main/org/media/naming/CVS/Root
                devel/spacemapper/mn8/src/main/org/media/naming/CVS/Repository
                devel/spacemapper/mn8/src/main/org/media/naming/CVS/Entries
                devel/spacemapper/mn8/src/main/org/media/naming/ReferenceRefAddr.java
                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/MemoryContext.java
                devel/spacemapper/mn8/src/main/org/media/naming/MemoryBinding.java
                devel/spacemapper/mn8/src/main/org/media/naming/package.html
            

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:
IOException :
(Error)
If unable to open tar archive.
IOException :
(Warning)
If could not add file to tar archive.

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

                $tarFile = Tar.create( "test.tar", false )                                                                                 
                
                $tarFile.add("This is a test", "text.txt")                                                                          
                $tarFile.add("This is another test", "text1.txt")                                                                   
                
                print $tarFile.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:
IOException :
(Error)
If unable to remove entry form tar archive.
pathNotFoundException :
(Error)
If unable to open tar archive.

Deletes the specified file from this archive.

                $tarFile = Tar.create( "test.tgz", true )                                                                                 
                $tarFile.add("This is a test", "text.txt")
                $tarFile.add("This is another test", "text1.txt")
                
                $tarFile.delete("text1.txt")
                
                print $tarFile.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:
fileExistsException :
(Warning)
If the file is already exists.
IOException :
(Error)
If unable to read tar archive.
pathNotFoundException :
(Error)
If unable to read tar archive.

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

                $tarFile = Tar.create( "test.tgz" )                                                                                 
                $tarFile.add("This is a test", "text.txt")
                $tarFile.add("This is another test", "text1.txt")
               
                print $tarFile.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:
fileExistsException :
(Warning)
If the file is already exists.
IOException :
(Error)
If unable to read tar archive.
pathNotFoundException :
(Error)
If unable to read tar archive.

Extracts all files from this archive in the specified directory.

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

top
list
Returns: Series
Exceptions:
IOException :
(Error)
If unable to open tar archive.

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

                $tarFile = Tar.create( "test.tar", false )                                                                                 
                $tarFile.add("This is a test", "text.txt")
                $tarFile.add("This is another test", "text1.txt")
                
                print $tarFile.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 :
(Warning)
If the entry not exists in tar archive.
IOException :
(Error)
If unable to read tar archive.

Returns the file content specified by the $path.

                $tarFile = Tar.create( "test.tar", false )                                                                                 
                $tarFile.add("This is a test", "text.txt")
                $tarFile.add("This is another test", "text1.txt")
                
                print $tarFile.wiew("text.txt")

                -- the result is --
                This is a test
            

top