Archive
The
Properties
Property | Type | Description |
---|---|---|
The full path to the archive file on disk | ||
An array of all entries in the archive | ||
The root directory of the archive | ||
Information about the archive's format |
Constructors
No Constructors
This type can not be created directly in scripts.
See:
Functions
Overview
General
Entry Manipulation
Entry Search
DirAtPath
Parameters
path (string ): The path of the directory to get
Returns
ArchiveDir : The directory in the archive atpath , ornil
if the path does not exist
Notes
If the archive does not support directories (eg. Doom Wad format) the 'root' directory is always returned, regardless of
EntryAtPath
Parameters
path (string ): The path of the entry to get
Returns
ArchiveEntry : The entry in the archive atpath , ornil
if no entry at the given path exists
Notes
If multiple entries exist with the same
FilenameNoPath
Gets the archive's
Returns
string : The archive'sfilename without the full path
Example
local archive = Archives.OpenFile('C:/games/doom/archive.wad')
App.LogMessage(archive:FilenameNoPath) -- 'archive.wad'
Save
Saves the archive to disk.
Parameters
[path] (string ): The full path to the file to save as. Default is""
, which will use the archive's existingfilename
Returns
boolean :true
if saving succeededstring : An error message if saving failed
Notes
If
Example
-- Open an archive
local archive = Archives.OpenFile('c:/filename.wad')
App.LogMessage(archive.filename) -- 'c:/filename.wad'
-- Save to existing file (c:/filename.wad)
local ok, err = archive:save()
if not ok then
App.LogMessage('Failed to save: ' .. err)
end
-- Save as new file
ok, err = archive:Save('c:/newfile.wad')
if not ok then
App.LogMessage('Failed to save as new file: ' .. err)
end
App.LogMessage(archive.filename) -- 'c:/newfile.wad'
CreateDir
Creates a new directory at
Parameters
path (string ): The path of the directory to create
Returns
ArchiveDir : The directory that was created ornil
if the archive format doesn't support directories
CreateEntry
Creates a new entry named
Parameters
fullPath (string ): The full path and name of the entry to createindex (integer ): The index to insert the entry
Returns
ArchiveEntry : The created entry
Notes
If the Archive is a format that supports directories, Scripts/NewScript.txt
.
The new entry will be inserted at -1
or larger than the number of entries in the destination directory, the new entry will be added at the end.
Example
-- Create entry in the root directory of a zip, after all other entries
newEntry = zip:CreateEntry('InRoot.txt', 0)
-- Create entry in a subdirectory of a zip, before all other entries in the subdirectory
newEntry = zip:CreateEntry('Path/To/NewEntry.txt', 1)
-- Create entry in the middle of a wad somewhere
newEntry = wad:CreateEntry('NEWENTRY', 12)
CreateEntryInNamespace
Creates a new entry named
Parameters
name (string ): The name of the entrynamespace (string ): The namespace to add the entry to
Returns
ArchiveEntry : The created entry
Notes
If the Archive supports directories,
See below for a list of supported namespaces:
Namespace | Wad Archive Markers | Zip Archive Directory |
---|---|---|
patches |
P_START / P_END |
patches |
sprites |
S_START / S_END |
sprites |
flats |
F_START / F_END |
flats |
textures |
TX_START / TX_END |
textures |
hires |
HI_START / HI_END |
hires |
colormaps |
C_START / C_END |
colormaps |
acs |
A_START / A_END |
acs |
voices |
V_START / V_END |
voices |
voxels |
VX_START / VX_END |
voxels |
sounds |
DS_START / DS_END |
sounds |
RemoveEntry
Removes the given
Parameters
entry (ArchiveEntry ): The entry to remove
Returns
boolean :false
if the entry was not found in the archive
RenameEntry
Renames the given entry.
Parameters
entry (ArchiveEntry ): The entry to renamename (string ): The new name for the entry
Returns
boolean :false
if the entry was not found in the archive
FindFirst
Parameters
options (ArchiveSearchOptions ): The search criteria
Returns
ArchiveEntry : The first entry found in the archive matching the givenoptions , ornil
if no match was found
Notes
If
FindLast
Parameters
options (ArchiveSearchOptions ): The search criteria
Returns
ArchiveEntry : The last entry found in the archive matching the givenoptions , ornil
if no match was found
Notes
If
FindAll
Parameters
options (ArchiveSearchOptions ): The search criteria
Returns
ArchiveEntry[] : All entries found in the archive matching the givenoptions , or an empty array if no match is found