jjg@57: /* ohair@554: * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. jjg@57: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@57: * jjg@57: * This code is free software; you can redistribute it and/or modify it jjg@57: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this jjg@57: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. jjg@57: * jjg@57: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@57: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@57: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@57: * version 2 for more details (a copy is included in the LICENSE file that jjg@57: * accompanied this code). jjg@57: * jjg@57: * You should have received a copy of the GNU General Public License version jjg@57: * 2 along with this work; if not, write to the Free Software Foundation, jjg@57: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@57: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jjg@57: */ jjg@57: jjg@57: package com.sun.tools.javac.file; jjg@57: jjg@57: import java.io.File; jjg@57: import java.io.IOException; jjg@57: import java.util.zip.ZipEntry; jjg@57: import java.util.zip.ZipFile; jjg@57: import javax.tools.JavaFileObject; jjg@57: jjg@103: import com.sun.tools.javac.file.RelativePath.RelativeDirectory; jjg@103: import com.sun.tools.javac.file.RelativePath.RelativeFile; jjg@103: import com.sun.tools.javac.util.List; jjg@103: jjg@333: /** jjg@581: *
This is NOT part of any supported API.
jjg@333: * If you write code that depends on this, you do so at your own risk.
jjg@333: * This code and its internal interfaces are subject to change or
jjg@333: * deletion without notice.
jjg@333: */
jjg@57: public class SymbolArchive extends ZipArchive {
jjg@57:
jjg@57: final File origFile;
jjg@103: final RelativeDirectory prefix;
jjg@57:
jjg@103: public SymbolArchive(JavacFileManager fileManager, File orig, ZipFile zdir, RelativeDirectory prefix) throws IOException {
jjg@103: super(fileManager, zdir, false);
jjg@57: this.origFile = orig;
jjg@57: this.prefix = prefix;
jjg@103: initMap();
jjg@57: }
jjg@57:
jjg@57: @Override
jjg@57: void addZipEntry(ZipEntry entry) {
jjg@57: String name = entry.getName();
jjg@103: if (!name.startsWith(prefix.path)) {
jjg@57: return;
jjg@57: }
jjg@103: name = name.substring(prefix.path.length());
jjg@57: int i = name.lastIndexOf('/');
jjg@103: RelativeDirectory dirname = new RelativeDirectory(name.substring(0, i+1));
jjg@57: String basename = name.substring(i + 1);
jjg@57: if (basename.length() == 0) {
jjg@57: return;
jjg@57: }
jjg@57: List