Package jetbrains.buildServer.zip
Interface ZipReader
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
AbstractZipReader
,InMemoryZipFactory.InMemoryArchive
,ZipReaderDecorator
public interface ZipReader extends Closeable
Readin files from an archive file.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes the opened zip file.boolean
doesFileExist(String name)
Checks whether the specified file exists in the archive.boolean
doesFileExist(Pattern namePattern)
Checks whether the file (specified by the given regular expression) exists in the archive.long
getFileSize(String name)
Returns the size of the (uncompressed) file.List<String>
listDirectoryFiles(String path)
Lists files that are in the specified directory.List<String>
listFiles(Pattern regexPattern)
Lists files which names match the given pattern.InputStream
openBinaryFile(String name)
Opens a binary file for read.BufferedReader
openTextFile(String name, Charset charset)
Opens a text file for read.
-
-
-
Method Detail
-
listFiles
List<String> listFiles(Pattern regexPattern)
Lists files which names match the given pattern.- Parameters:
regexPattern
- a file name pattern, applies to the path and file name. Note: the path units separator is always '/' (a unix slash). Mandatory.- Returns:
- list of file names, ordered as the related files are placed in the archive file.
-
listDirectoryFiles
List<String> listDirectoryFiles(String path)
Lists files that are in the specified directory.For example, if the archive contains following files:
aaa/xxx/f1.txt aaa/xxx/ttt/f2.txt aaa/yyy/f3.txt
We calling this function with "aaa/xxx", it will return:f1.txt ttt/f2.txt
- Parameters:
path
- directory path.- Returns:
- list of file names related to the give path, ordered as the related files are placed in the archive file.
-
getFileSize
long getFileSize(String name)
Returns the size of the (uncompressed) file.- Parameters:
name
- file name.- Returns:
- size of file, in bytes; or
Long.MIN_VALUE
if file doesn't exist.
-
openTextFile
@NotNull BufferedReader openTextFile(@NotNull String name, @Nullable Charset charset) throws IOException, IllegalArgumentException
Opens a text file for read.- Parameters:
name
- name of the file to open.charset
- desired character set, or null for using the default character set.- Returns:
- text input stream.
- Throws:
IOException
FileNotFoundException
- if no entry withname
has been found in the archive.IllegalArgumentException
-
openBinaryFile
@NotNull InputStream openBinaryFile(@NotNull String name) throws IOException, IllegalArgumentException
Opens a binary file for read.- Parameters:
name
- name of the file to open.- Returns:
- binary input stream.
- Throws:
IOException
FileNotFoundException
- if no entry withname
has been found in the archive.IllegalArgumentException
-
doesFileExist
boolean doesFileExist(@NotNull String name)
Checks whether the specified file exists in the archive.- Parameters:
name
- name of the file to check for existence.- Returns:
- file exists.
-
doesFileExist
boolean doesFileExist(@NotNull Pattern namePattern)
Checks whether the file (specified by the given regular expression) exists in the archive.- Parameters:
name
- file name regular expression.- Returns:
- file exists.
-
close
void close()
Closes the opened zip file.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-