Class ArchiveWriter
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
VASSAL.tools.DataArchive
VASSAL.tools.ArchiveWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
An ArchiveWriter is a writeable DataArchive. New files may be added
with the
addFile(java.lang.String, java.lang.String)
and addImage(java.lang.String, java.lang.String)
methods. save()
and saveAs()
will
cause the archive to be written out, with FileChooser invoked if appropriate.-
Field Summary
Fields inherited from class VASSAL.tools.DataArchive
archive, cachedLocalImages, extensions, ICON_DIR, IMAGE_DIR, imageDir, localImages, SOUND_DIR, soundDir
-
Constructor Summary
ConstructorDescriptionArchiveWriter
(String zipName) Create a new writeable archive.ArchiveWriter
(String zipName, String defaultExtension) Create a new writeable archive.ArchiveWriter
(FileArchive archive) ArchiveWriter
(FileArchive archive, String defaultExtension) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copy am array ofbytes
into the archivevoid
addFile
(String fileName, InputStream in) Copy anInputStream
into the archivevoid
Copy a file from the user's filesystem to the archive.void
void
Add an image file to the archive.void
void
removeFile
(String name) Removes a file in the archivevoid
removeImage
(String name) void
save()
void
save
(boolean notifyModuleManager) void
saveAs()
void
saveAs
(boolean notifyModuleManager) boolean
Saves the archive, always prompting for a new filename.boolean
saveAsButVerify
(boolean notifyModuleManager) Saves the archive, always prompting for a new filename.boolean
Saves the archive, prompting for a name only if none has ever been provided.boolean
saveButVerify
(boolean notifyModuleManager) Saves the archive, prompting for a name only if none has ever been provided.protected void
write
(FileArchive fa, boolean notifyModuleManager) Writes the file archive.Methods inherited from class VASSAL.tools.DataArchive
addExtension, buildLocalizedDirectoryList, close, contains, contains, findClass, getAllLocalImageNames, getAllLocalImageNamesForDirectory, getArchive, getCachedAudioClip, getImageNames, getImageNameSet, getImageNameSet, getImageNamesRecursively, getImageNamesRecursively, getImagePrefix, getInputStream, getLocalImageNames, getName, getPermissions, getURL, getURL, getWriter, loadClass
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
ArchiveWriter
Create a new writeable archive.- Parameters:
zipName
- the name of the archive. If null, the user will be prompted for a filename when saving. If not null, new entries will be added to the named archive. If the file exists and is not a zip archive, it will be overwritten.defaultExtension
- the default file extension for the archive. If non-null, and the user needs to be prompted for a filename, this will be the default file extension added automatically.
-
ArchiveWriter
-
ArchiveWriter
Create a new writeable archive.- Parameters:
zipName
- the name of the archive. If null, the user will be prompted for a filename when saving. If not null, new entries will be added to the named archive. If the file exists and is not a zip archive, it will be overwritten.
-
ArchiveWriter
-
-
Method Details
-
addImage
Add an image file to the archive. The file will be copied into an "images" directory in the archive. Storing another image with the same name will overwrite the previous image.- Parameters:
path
- the full path of the image file on the user's filesystemname
- the name under which to store the image in the archive
-
addImage
-
addSound
-
removeImage
-
removeFile
Removes a file in the archive- Parameters:
name
- file in the archive to be removed
-
addFile
-
addFile
Copy anInputStream
into the archive- Parameters:
fileName
- the name under which to store the contents of the streamin
- the stream to copy
-
addFile
Copy am array ofbytes
into the archive- Parameters:
fileName
- the name under which to store the contents of the streamcontent
- array of bytes to copy
-
save
- Throws:
IOException
-
save
- Throws:
IOException
-
saveAs
- Throws:
IOException
-
saveAs
- Throws:
IOException
-
saveButVerify
Saves the archive, prompting for a name only if none has ever been provided.- Throws:
IOException
- IOException
-
saveButVerify
Saves the archive, prompting for a name only if none has ever been provided.- Parameters:
notifyModuleManager
- If true, notifies Module Manager that the save has occurred- Throws:
IOException
- IOException
-
saveAsButVerify
Saves the archive, always prompting for a new filename.- Throws:
IOException
- IOException
-
write
Writes the file archive.- Parameters:
fa
- File archivenotifyModuleManager
- if true, notifies the module manager that a file has been saved.- Throws:
IOException
- IOException
-
saveAsButVerify
Saves the archive, always prompting for a new filename. If a defaultExtension has been provided, it will be added to the filename unless the user specifies a different one explicitly.- Parameters:
notifyModuleManager
- If true, notifies Module Manager that the save has occurred- Returns:
- true if operation proceeded, false if it was cancelled by user at file chooser or confirmation dialog
- Throws:
IOException
- IOException
-