Package VASSAL.tools.io
Interface FileArchive
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
ZipArchive
- Since:
- 3.2.0
- Author:
- Joel Uckelman
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the contents of a byte array to the archive.voidAdds a file to the archive.voidadd(String path, InputStream in)Adds the contents of anInputStreamto the archive.voidAdds a file to the archive.voidclose()Closes the archive, writing all changes to disk.booleanQueries whether a file exists in the archive.voidflush()Forces all changes to the archive to disk.default longgetCompressedSize(String path)Get the compressed size of a file in the archive, in bytes.getFile()Gets the path to the archive file.getFiles()Gets the list of files in the archive.Gets the list of files under a given directory of the archive.getInputStream(String path)Gets anInputStreamto read from the given file.longGets the modification time of a file in the archive, in milliseconds since the epoch.getName()Gets the path to the archive file.getOutputStream(String path)Gets anOutputStreamto write to the given file.longGets the size of a file in the archive, in bytes.booleanisClosed()Queries whether the archive is closed.booleanQueries whether the archive has unsaved modifications.booleanRemoves a file from the archive.voidrevert()Reverts the archive to its last saved state.
-
Method Details
-
getName
String getName()Gets the path to the archive file.- Returns:
- the path as a
String
-
getFile
File getFile()Gets the path to the archive file.- Returns:
- the path as a
File
-
getInputStream
Gets anInputStreamto read from the given file.- Parameters:
path- the path to the file in the archive- Returns:
- an
InputStreamcontaining the requested file - Throws:
IOException- oops
-
getOutputStream
Gets anOutputStreamto write to the given file.- Parameters:
path- the path to the file in the archive- Returns:
- an
OutputStreamfor the requested file - Throws:
IOException- oops
-
add
Adds a file to the archive.- Parameters:
path- the internal path of the file to be addedextPath- the external path of the file to be added- Throws:
IOException- oops
-
add
Adds a file to the archive.- Parameters:
path- the internal path of the file to be addedextPath- the external path to the file to be added- Throws:
IOException- oops
-
add
Adds the contents of a byte array to the archive.- Parameters:
path- the internal path of the file to be addedbytes- the bytes to be added- Throws:
IOException- oops
-
add
Adds the contents of anInputStreamto the archive.- Parameters:
path- the internal path of the file to be addedin- theInputStreamto read from- Throws:
IOException- oops
-
remove
Removes a file from the archive.- Parameters:
path- the path to the file in the archive- Returns:
trueif the file existed in the archive- Throws:
IOException- oops
-
revert
Reverts the archive to its last saved state.- Throws:
IOException- oops
-
flush
Forces all changes to the archive to disk.- Throws:
IOException- oops
-
close
Closes the archive, writing all changes to disk.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- oops
-
contains
Queries whether a file exists in the archive.- Parameters:
path- the path to the file in the archive- Returns:
trueif the file exists in the archive- Throws:
IOException- oops
-
isClosed
boolean isClosed()Queries whether the archive is closed.- Returns:
trueif the archive is closed
-
isModified
boolean isModified()Queries whether the archive has unsaved modifications.- Returns:
trueif the archive is modified
-
getSize
Gets the size of a file in the archive, in bytes.- Parameters:
path- the path to the file in the archive- Returns:
- the size of the file, in bytes
- Throws:
FileNotFoundException- ifpathis not in the archiveIOException- oops
-
getCompressedSize
Get the compressed size of a file in the archive, in bytes. Rerurn the uncompressed size by default.- Returns:
- the compressed size of the file, in bytes
- Throws:
FileNotFoundException- ifpathis not in the archiveIOException- oops
-
getMTime
Gets the modification time of a file in the archive, in milliseconds since the epoch.- Parameters:
path- the path to the file in the archive- Returns:
- the mtime of the file
- Throws:
FileNotFoundException- ifpathis not in the archiveIOException- oops
-
getFiles
Gets the list of files in the archive.- Returns:
- the list of files in the archive
- Throws:
IOException- oops
-
getFiles
Gets the list of files under a given directory of the archive.- Parameters:
root- the directory- Returns:
- the list of files under the given directory
- Throws:
FileNotFoundException- ifrootis not in the archiveIOException- oops
-