Method from com.sun.tools.javac.file.ZipFileIndex Detail: |
public synchronized void close() {
writeIndex();
closeFile();
}
|
public synchronized boolean contains(RelativePath path) {
try {
checkIndex();
return getZipIndexEntry(path) != null;
}
catch (IOException e) {
return false;
}
}
Tests if a specific path exists in the zip. This method will return true
for file entries and directories. |
protected void finalize() throws Throwable {
closeFile();
super.finalize();
}
|
File getAbsoluteFile() {
File absFile = (absFileRef == null ? null : absFileRef.get());
if (absFile == null) {
absFile = zipFile.getAbsoluteFile();
absFileRef = new SoftReference< File >(absFile);
}
return absFile;
}
|
public synchronized Set<RelativeDirectory> getAllDirectories() {
try {
checkIndex();
if (allDirs == Collections.EMPTY_SET) {
allDirs = new HashSet< RelativeDirectory >(directories.keySet());
}
return allDirs;
}
catch (IOException e) {
return Collections.< RelativeDirectory >emptySet();
}
}
|
public synchronized List<String> getDirectories(RelativeDirectory path) {
try {
checkIndex();
DirectoryEntry de = directories.get(path);
com.sun.tools.javac.util.List< String > ret = de == null ? null : de.getDirectories();
if (ret == null) {
return com.sun.tools.javac.util.List.< String >nil();
}
return ret;
}
catch (IOException e) {
return com.sun.tools.javac.util.List.< String >nil();
}
}
|
public synchronized List<String> getFiles(RelativeDirectory path) {
try {
checkIndex();
DirectoryEntry de = directories.get(path);
com.sun.tools.javac.util.List< String > ret = de == null ? null : de.getFiles();
if (ret == null) {
return com.sun.tools.javac.util.List.< String >nil();
}
return ret;
}
catch (IOException e) {
return com.sun.tools.javac.util.List.< String >nil();
}
}
Returns a javac List of filenames within a directory in the ZipFileIndex. |
public synchronized long getLastModified(RelativeFile path) throws IOException {
Entry entry = getZipIndexEntry(path);
if (entry == null)
throw new FileNotFoundException();
return entry.getLastModified();
}
|
public File getZipFile() {
return zipFile;
}
|
public long getZipFileLastModified() throws IOException {
synchronized (this) {
checkIndex();
return zipFileLastModified;
}
}
Returns the last modified timestamp of a zip file. |
synchronized Entry getZipIndexEntry(RelativePath path) {
try {
checkIndex();
DirectoryEntry de = directories.get(path.dirname());
String lookFor = path.basename();
return (de == null) ? null : de.getEntry(lookFor);
}
catch (IOException e) {
return null;
}
}
Returns the ZipFileIndexEntry for a path, if there is one. |
public synchronized boolean isDirectory(RelativePath path) throws IOException {
// The top level in a zip file is always a directory.
if (path.getPath().length() == 0) {
lastReferenceTimeStamp = System.currentTimeMillis();
return true;
}
checkIndex();
return directories.get(path) != null;
}
|
public synchronized boolean isOpen() {
return (zipRandomFile != null);
}
|
public synchronized int length(RelativeFile path) throws IOException {
Entry entry = getZipIndexEntry(path);
if (entry == null)
throw new FileNotFoundException();
if (entry.isDir) {
return 0;
}
byte[] header = getHeader(entry);
// entry is not compressed?
if (get2ByteLittleEndian(header, 8) == 0) {
return entry.compressedSize;
} else {
return entry.size;
}
}
|
public synchronized byte[] read(RelativeFile path) throws IOException {
Entry entry = getZipIndexEntry(path);
if (entry == null)
throw new FileNotFoundException("Path not found in ZIP: " + path.path);
return read(entry);
}
|
synchronized byte[] read(Entry entry) throws IOException {
openFile();
byte[] result = readBytes(entry);
closeFile();
return result;
}
|
public synchronized int read(RelativeFile path,
byte[] buffer) throws IOException {
Entry entry = getZipIndexEntry(path);
if (entry == null)
throw new FileNotFoundException();
return read(entry, buffer);
}
|
synchronized int read(Entry entry,
byte[] buffer) throws IOException {
int result = readBytes(entry, buffer);
return result;
}
|
public String toString() {
return "ZipFileIndex[" + zipFile + "]";
}
|
public boolean writeZipIndex() {
synchronized (this) {
return writeIndex();
}
}
|