Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcArchiveEntry

Archive::ezcArchiveEntry

Class ezcArchiveEntry

The ezcArchiveEntry class provides system-independent file information.

ezcArchiveEntry provides file information about the file path, it's access rights and whether the file is an directory, symbolic link, hard link, block-file, etc. The owner name, the group name, the last access time are also available. ezcArchiveEntry can be used to get the file information directly from the file-system or from an archive.

The main purpose of ezcArchiveEntry is to provide information about:

  • Files on the file-system that should be appended to the archive.
  • Files currently in the archive that can be extracted to the file-system.
Use the getEntryFromFile() to create an ezcArchiveEntry from a file in the filesystem. Important is that the prefix is set. This specifies which part of the path should be stripped, before the entry is appended to the archive. See also ezcArchive::append() or ezcArchive::appendToCurrent().

When the ezcArchiveEntry is an entry in the archive, the getPath() method contains always an relative path, and the prefix is not set.

Source for this file: /Archive/src/entry.php

Version:   //autogentag//

Constants

IS_BLOCK_DEVICE = 4 Is a block device.
IS_CHARACTER_DEVICE = 3 Is a character device.
IS_DIRECTORY = 5 Is a directory.
IS_FIFO = 6 Is a FIFO.
IS_FILE = 0 Is a regular file.
IS_LINK = 1 Is a hard link.
IS_RESERVED = 7 Not used, is Tar specific?
IS_SYMBOLIC_LINK = 2 Is a symbolic link.

Member Variables

protected ezcArchiveFileStructure $fileStructure
Contains the file information.
protected string $prefix
The prefix of the file that may be removed from the path.

Method Summary

public static ezcArchiveEntry getEntryFromFile( $files , $prefix )
Returns one or an array of ezcArchiveEntry's from one or multiple files in the file system.
protected static ezcArchiveFileStructure getFileStructureFromFile( $file )
Create a file structure from a $file in the file system.
protected static int getLinkType( $stat )
Returns an ezcArchiveEntry-type that corresponds to the ezcArchiveStatMode-type
public ezcArchiveEntry __construct( $struct )
Constructs an archiveEntry from the ezcArchiveFileStructure.
public int getAccessTime( )
Returns the last access time as a timestamp.
public int getDevice( )
Returns the device.
public int getGroupId( )
Returns the group ID of the entry.
public int getInode( )
Returns the inode.
public void getLink( [ $withPrefix = true] )
Returns the link with or without prefix.
public int getMajor( )
Returns the major device number.
public int getMinor( )
Returns the minor device number.
public int getModificationTime( )
Returns the modification time as a timestamp.
public string getPath( [ $withPrefix = true] )
Returns the complete path or path without the prefix.
public string getPermissions( )
Returns a bit mask representing the permissions of this entry.
public string getPermissionsString( )
Returns the permissions as a string.
public string getPrefix( )
Returns the prefix.
public int getSize( )
Returns the file size.
public int getType( )
Returns type of the entry.
public string getTypeString( )
Returns the type string for the current type of the entry.
public int getUserId( )
Returns the user ID of the entry.
public bool isDirectory( )
Returns true when this entry represents a directory.
public bool isFile( )
Returns true when this entry represents a file.
public bool isHardLink( )
Returns true when this entry represents a hard link.
public bool isLink( )
Returns true when this entry represents a symbolic or a hard link.
public bool isSymLink( )
Returns true when this entry represents a symbolic link.
public void removePrefixFromPath( )
Removes the prefix from the path and clears the prefix.
public void setPrefix( $prefix )
Sets the prefix.
public string __toString( )
Returns a string representing the current entry.

Methods

getEntryFromFile

static ezcArchiveEntry getEntryFromFile( string|array(string) $files , string $prefix )

Returns one or an array of ezcArchiveEntry's from one or multiple files in the file system.

One or multiple ezcArchiveEntry's are created upon the given files. The prefix will directly set for the ezcArchiveEntry with $prefix.

If $files contains a path to a file, then one ezcArchiveEntry will be created and returned. If $files is an array of paths, then all those ezcArchiveEntry's will be created and returned in an array.

When multiple files are given in an array, this method will search for hard links among other files in the array.

Parameters:
Name Type Description
$files string|array(string)
$prefix string
Exceptions:
Type Description
ezcArchiveEntryPrefixException if the prefix is invalid.

getFileStructureFromFile

static ezcArchiveFileStructure getFileStructureFromFile( string $file )

Create a file structure from a $file in the file system.

Parameters:
Name Type Description
$file string

getLinkType

static int getLinkType( ezcArchiveStatMode $stat )

Returns an ezcArchiveEntry-type that corresponds to the ezcArchiveStatMode-type

Parameters:
Name Type Description
$stat ezcArchiveStatMode Possible values are: ezcArchiveStatMode::S_IFIFO, ezcArchiveStatMode::S_IFCHR, ezcArchiveStatMode::S_IFDIR, ezcArchiveStatMode::S_IFBLK, ezcArchiveStatMode::S_IFREG, or ezcArchiveStatMode::S_IFLNK.

__construct

ezcArchiveEntry __construct( $struct )

Constructs an archiveEntry from the ezcArchiveFileStructure.

The $struct parameter contains the raw file information. This class encapsulates the file information structure and provides convenient methods to retrieve the information.

Parameters:
Name Type Description
$struct ezcArchiveFileStructure

getAccessTime

int getAccessTime( )

Returns the last access time as a timestamp.

getDevice

int getDevice( )

Returns the device.

FIXME DEPRECATED?

getGroupId

int getGroupId( )

Returns the group ID of the entry.

getInode

int getInode( )

Returns the inode.

getLink

void getLink( [bool $withPrefix = true] )

Returns the link with or without prefix.

This method is similar to getPath(), but returns the link instead of the path. If the current does not represents a link, an empty string is returned. Use the isLink() method to see if the current entry is a link.

Parameters:
Name Type Description
$withPrefix bool

getMajor

int getMajor( )

Returns the major device number.

getMinor

int getMinor( )

Returns the minor device number.

getModificationTime

int getModificationTime( )

Returns the modification time as a timestamp.

getPath

string getPath( [bool $withPrefix = true] )

Returns the complete path or path without the prefix.

By default the full path is returned, unless the $withPrefix is set to true.

Parameters:
Name Type Description
$withPrefix bool

getPermissions

string getPermissions( )

Returns a bit mask representing the permissions of this entry.

It returns the permissions in octal numbers as a string, for example: "0000755"

getPermissionsString

string getPermissionsString( )

Returns the permissions as a string.

If the entry has all the permissions, it will return: "rwxrwx" Where the first three letters represent the group permissions and the last three letters the user permissions.

getPrefix

string getPrefix( )

Returns the prefix.

getSize

int getSize( )

Returns the file size.

getType

int getType( )

Returns type of the entry.

getTypeString

string getTypeString( )

Returns the type string for the current type of the entry.

Returns a type string for the current entry. If the entry is a:

  • directory: "d".
  • file: "-".
  • symbolic link: "l".
  • hard link: "h".

getUserId

int getUserId( )

Returns the user ID of the entry.

isDirectory

bool isDirectory( )

Returns true when this entry represents a directory.

isFile

bool isFile( )

Returns true when this entry represents a file.

isHardLink

bool isHardLink( )

Returns true when this entry represents a hard link.

isLink

bool isLink( )

Returns true when this entry represents a symbolic or a hard link.

isSymLink

bool isSymLink( )

Returns true when this entry represents a symbolic link.

removePrefixFromPath

void removePrefixFromPath( )

Removes the prefix from the path and clears the prefix.

This method is useful when it comes to adding a entry to an archive and the complete path to the file is no longer needed.

setPrefix

void setPrefix( string $prefix )

Sets the prefix.

Parameters:
Name Type Description
$prefix string

__toString

string __toString( )

Returns a string representing the current entry.

Documentation generated by phpDocumentor 1.4.3