Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members  

PLMArchPAK Class Reference

Archive handler for Quake (1 & 2) .pak archives. More...

#include <PLMArchives.hpp>

Inheritance diagram for PLMArchPAK:

Inheritance graph
[legend]
List of all members.

Public Methods

virtual const char * FormatInfo () const
virtual bool Create (const char *filename)
virtual bool Open (const char *filename)
virtual void Close ()
virtual u32 AddFile (const char *filename, const char *entryname)
virtual bool RemoveFile (u32 index)
virtual bool RenameFile (u32 index, const char *filename)
virtual bool UpdateFile (u32 index, const char *filename)
virtual bool ExtractFile (u32 index, const char *filename) const
virtual PLMResFileOpenResFile (u32 index) const
virtual const char * Name () const
virtual u32 NbFiles () const
virtual PLMResFileOpenFile (const char *name) const
virtual PLMResFileOpenFile (const iterator &it) const=0
virtual bool CopyFile (const char *name, const char *path) const
virtual void PrintInfo () const
int Format () const
virtual u32 FindFile (const char *filename) const
virtual bool ExtractAll (const char *dirname) const
virtual u32 TotalSize () const
const ArchiveEntryGetEntry (u32 index) const
void PrintContent () const
virtual void Update ()
iterator Begin () const
iterator End () const
siterator SBegin () const
siterator SEnd () const
virtual void Sort (int how)

Static Public Methods

PLMArchiveOpenArchive (const char *name)
int FindArchiveFormat (const char *filename)

Protected Methods

virtual const char * FileName (u32 i) const
virtual u32 FileSize (u32 i) const
virtual time_t FileDate (u32 i) const
virtual bool FileAccess (u32 i, u32 perm_flags) const
virtual bool IsFileHidden (u32 i) const
virtual bool IsFile (u32 i) const
virtual bool IsFileLink (u32 i) const
virtual bool IsFileDir (u32 i) const
virtual int CompareFunc (const PLMSortableItem *f1, const PLMSortableItem *f2) const
virtual PLMSortableItemGetItem (u32 i) const
u32 SortedIndex (u32 i) const
u32 IterIndex (const iterator &it) const

Detailed Description

Archive handler for Quake (1 & 2) .pak archives.


Member Function Documentation

virtual const char* PLMArchPAK::FormatInfo   [virtual]
 

Get a description of the archive file format. Do not try to delete the string.

Implements PLMArchive.

virtual bool PLMArchPAK::Create const char *    filename [virtual]
 

Try to create an empty archive.

Will fail if the file already exists.

Implements PLMArchive.

virtual bool PLMArchPAK::Open const char *    filename [virtual]
 

Try to open an existing archive.

Load archive content (file list).

Implements PLMArchive.

void PLMArchPAK::Close   [inline, virtual]
 

Close the current archive.

No operation can then be performed until a new Open() or Create().

Reimplemented from PLMArchive.

virtual u32 PLMArchPAK::AddFile const char *    filename,
const char *    entryname
[virtual]
 

Add a file to the current archive (at the end).

Parameters:
filename  name of the real file to add (must exist and be readable)
entryname  name to use in the archive for this file, filename is used if NULL.
Returns:
the index of the file in the archive on success, PLM::INDEX_ERROR otherwise. The archive main file is modified.

Implements PLMArchive.

virtual bool PLMArchPAK::RemoveFile u32    index [virtual]
 

Try to remove a file from the archive.

Use FindFile() to get its index, if you know its name. The archive main file is modified.

Implements PLMArchive.

virtual bool PLMArchPAK::RenameFile u32    index,
const char *    filename
[virtual]
 

Change the name of the file at index to filename.

The archive main file is modified.

Implements PLMArchive.

virtual bool PLMArchPAK::UpdateFile u32    index,
const char *    filename
[virtual]
 

Replace the content of the file at index inside the archive with the data from the file named filename (even if the names are different).

The name of the file in the archive is not modified anyway. The archive main file is modified.

Implements PLMArchive.

virtual bool PLMArchPAK::ExtractFile u32    index,
const char *    filename
const [virtual]
 

Create a real file named filename and copy the content from the archive file at index inside it.

Implements PLMArchive.

virtual PLMResFile* PLMArchPAK::OpenResFile u32    index const [virtual]
 

Get a PLMResFile directly opened on a file inside the archive.

It must be deleted after use. Note that you must stop to use it if any modifications are made to the archive (such as RemoveFile() or UpdateFile()).

Parameters:
index  the internal index of the file inside the archive, get it with FindFile() or iterator::Index()
Returns:
a valid file pointer (that must be deleted after use) or NULL if the index is not valid.

Implements PLMArchive.

PLMArchive* PLMArchive::OpenArchive const char *    name [static, inherited]
 

This static method allows to easily open an archive and automatically find its type (file format).

You have to delete the pointer yourself. Return a valid archive pointer on success or NULL on failure.

int PLMArchive::FindArchiveFormat const char *    filename [static, inherited]
 

Try to open the file named filename, and guess the right archive format.

Returns:
the archive format found or ARCH_UNK on error (if not a known format or can not open/read the file).

virtual const char* PLMArchive::Name   const [inline, virtual, inherited]
 

Get archive name (file name). Can be NULL if no archive has been loaded/created.

Implements PLMFileProvider.

virtual u32 PLMArchive::NbFiles   const [inline, virtual, inherited]
 

Get the total number of files inside the archive.

Implements PLMFileProvider.

PLMResFile * PLMArchive::OpenFile const char *    name const [inline, virtual, inherited]
 

Try to open the file (in read-only mode) named name (may contain a relative path).

Returns:
a valid file pointer (that must be deleted after use) on success, or NULL on error.

Implements PLMFileProvider.

virtual PLMResFile* PLMFileProvider::OpenFile const iterator &    it const [pure virtual, inherited]
 

Try to open the file (in read-only mode) pointed by the iterator it.

Returns:
a valid file pointer (that must be deleted after use) on success, or NULL on error.

bool PLMArchive::CopyFile const char *    name,
const char *    path
const [inline, virtual, inherited]
 

Copy the file named name (in the archive) into a new (real) location in the file system given by path.

If path contains a file name, then the file is also renamed. Returns true on success.

Implements PLMFileProvider.

virtual void PLMArchive::PrintInfo   [virtual, inherited]
 

Print some debug information to current log.

Implements PLMFileProvider.

int PLMArchive::Format   const [inline, inherited]
 

Get archive file format (one of ARCH_*).

virtual u32 PLMArchive::FindFile const char *    filename const [virtual, inherited]
 

Try to find a file inside the archive.

This index can then be used with other methods. Note that the index is valid while the archive is not modified (add or remove files).

Returns:
the file index on success, PLM::INDEX_ERROR if it fails.

virtual bool PLMArchive::ExtractAll const char *    dirname const [virtual, inherited]
 

Extract all files inside the archive to the given directory dirname.

The directory must already exist. Return false on error.

virtual u32 PLMArchive::TotalSize   [virtual, inherited]
 

Get total data size in bytes (sum of all files sizes in the archive).

const ArchiveEntry* PLMArchive::GetEntry u32    index const [inline, inherited]
 

Get entry at index. May return 0 if index is out of bounds.

void PLMArchive::PrintContent   [inherited]
 

Print the list of files currently in the archive.

const char * PLMArchive::FileName u32    i const [inline, protected, virtual, inherited]
 

Get the name (read-only) of the file at index i (from an iterator).

Implements PLMFileProvider.

u32 PLMArchive::FileSize u32    i const [inline, protected, virtual, inherited]
 

Get the total size in bytes of the file at index i (from an iterator).

Implements PLMFileProvider.

time_t PLMArchive::FileDate u32    i const [inline, protected, virtual, inherited]
 

Get the date of the file at index i (from an iterator).

Implements PLMFileProvider.

bool PLMArchive::FileAccess u32    i,
u32    perm_flags
const [inline, protected, virtual, inherited]
 

Get the access mode of the file at index i (from an iterator).

Implements PLMFileProvider.

bool PLMArchive::IsFileHidden u32    i const [inline, protected, virtual, inherited]
 

Check if the file at index i (from an iterator) is hidden.

Implements PLMFileProvider.

bool PLMArchive::IsFile u32    i const [inline, protected, virtual, inherited]
 

Check if the element at index i (from an iterator) is a standard file (not a link or a folder).

Implements PLMFileProvider.

bool PLMArchive::IsFileLink u32    i const [inline, protected, virtual, inherited]
 

Check if the element at index i (from an iterator) is a link (false under win32).

Implements PLMFileProvider.

bool PLMArchive::IsFileDir u32    i const [inline, protected, virtual, inherited]
 

Check if the element at index i (from an iterator) is a directory.

Implements PLMFileProvider.

virtual int PLMArchive::CompareFunc const PLMSortableItem   f1,
const PLMSortableItem   f2
const [protected, virtual, inherited]
 

Determine order between two items.

Returns:
  • if f1 = f2, return 0
  • if f1 < f2, a negative value
  • if f1 > f2, a positive value

Implements PLMFileProvider.

PLMSortableItem * PLMArchive::GetItem u32    i const [inline, protected, virtual, inherited]
 

Get the real internalindex of the i-th sorted element.

Implements PLMFileProvider.

virtual void PLMFileProvider::Update   [inline, virtual, inherited]
 

Force the source to update its content list.

Items are automatically sorted if Sort() has already been called.

Reimplemented in PLMDir.

iterator PLMFileProvider::Begin   const [inline, inherited]
 

Get an interator pointing on the first element of the current list.

iterator PLMFileProvider::End   const [inline, inherited]
 

Get an interator pointing just after the last element of the current list.

Usually to be compared with another iterator to find the end. Call iterator.Last() to get an iterator on the last element.

siterator PLMFileProvider::SBegin   const [inline, inherited]
 

Get a 'sorted' iterator pointing on the first item of the sorted list.

The sorted iterator will run through the list in the order set by the last call to Sort().

siterator PLMFileProvider::SEnd   const [inline, inherited]
 

Get a 'sorted' iterator pointing just after the last item of the sorted list.

Usually to be compared with another iterator to find the end. Call siterator.Last() to get an iterator on the last element.

virtual void PLMFileProvider::Sort int    how [virtual, inherited]
 

Change the order of the list.

Use PLM::SortFlags constants to select an order. Only one of SORT_NAME/SIZE/DATE/EXT can be selected and OR-ed with the other flags REVERSE, CASE and/or DIRS. Later calls to Open() and Update() will automatically use the same settings. Note that only SortedIterators will parse the list in the right order, standard iterators always use the native order (SORT_NONE). After a call to Sort(), any existing s(orted)iterator are not valid anymore, you should get a new one.

u32 PLMFileProvider::SortedIndex u32    i const [inline, protected, inherited]
 

Get the "real" internal index of the i-th sorted element (from an iterator).

u32 PLMFileProvider::IterIndex const iterator &    it const [inline, protected, inherited]
 

Get the internal index of the iterator.


The documentation for this class was generated from the following file:
  • PLMArchives.hpp

Generated by Doxygen 1.2.18 on Tue Oct 26 12:07:43 2004.