Archive

The Archive type represents an archive (wad/pk3/etc) in SLADE.

Properties

Property Type Description
filename string The full path to the archive file on disk
entries ArchiveEntry[] An array of all entries in the archive
rootDir ArchiveDir The root directory of the archive
format ArchiveFormat Information about the archive's format

Constructors

No Constructors

This type can not be created directly in scripts.

See:

Functions

getDir

Parameters

  • string path: The path of the directory to get

Returns ArchiveDir

Returns the directory in the archive at path, or nil if the path does not exist. If the archive does not support directories (eg. Doom Wad format) the 'root' directory is always returned, regardless of path.


createEntry

Parameters

  • string full_path: The full path and name of the entry to create
  • number position: The position to insert the entry

Returns ArchiveEntry

Creates a new entry named full_path in the Archive. If the Archive is a format that supports directories, full_path can optionally contain a path eg. Scripts/NewScript.txt.

The new entry will be inserted at position in the directory it is added to (always the root for Archives that don't support directories). If position is negative 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', -1)

-- Create entry in a subdirectory of a zip, before all other entries in the subdirectory
newEntry = zip:createEntry('Path/To/NewEntry.txt', 0)

-- Create entry in the middle of a wad somewhere
newEntry = wad:createEntry('NEWENTRY', 12)

createEntryInNamespace

Parameters

  • string name: The name of the entry
  • string namespace: The namespace to add the entry to

Returns ArchiveEntry

Creates a new entry named name in the Archive, at the end of namespace. If the Archive supports directories, namespace can be a path.

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

Parameters

Returns boolean

Removes the given entry from the archive (but does not delete it). Returns false if the entry was not found in the archive.


renameEntry

Parameters

  • ArchiveEntry entry: The entry to rename
  • string name: The new name for the entry

Returns boolean

Renames the given entry. Returns false if the entry was not found in the archive.


save

Parameters

  • [string path]: The full path to the file to save as

Returns boolean

Saves the archive to disk. If no path path is given, the archive's current filename is used.

If path is given, this will work like 'Save As' - the archive will be saved to a new file at the given path, overwriting the file if it already exists. This will also update the filename property.

Example

-- Open an archive
local archive = Archives.openFile('c:/filename.wad')
App.logMessage(archive.filename) -- 'c:/filename.wad'

-- Save as new file
archive:save('c:/newfile.wad')

App.logMessage(archive.filename) -- 'c:/newfile.wad'