/[classpath]/classpath/java/util/jar/JarFile.java
ViewVC logotype

Diff of /classpath/java/util/jar/JarFile.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by mark, Fri Nov 22 03:09:04 2002 UTC revision 1.7 by mark, Fri Nov 29 14:04:19 2002 UTC
# Line 67  public class JarFile extends ZipFile Line 67  public class JarFile extends ZipFile
67    
68    /**    /**
69     * The manifest of this file, if any, otherwise null.     * The manifest of this file, if any, otherwise null.
70     * Read by the constructor.     * Read when first needed.
71     */     */
72    private final Manifest manifest;    private Manifest manifest;
73    
74    /** Wether to verify the manifest and all entries */    /** Wether to verify the manifest and all entries. */
75    private boolean verify;    private boolean verify;
76    
77      /** Wether the has already been loaded. */
78      private boolean manifestRead = false;
79    
80    // Constructors    // Constructors
81    
82    /**    /**
83     * Creates a new JarFile, tries to read the manifest and if the manifest     * Creates a new JarFile. All jar entries are verified (when a Manifest file
84     * exists verifies it.     * for this JarFile exists). You need to actually open and read the complete
85       * jar entry (with <code>getInputStream()</code>) to check its signature.
86     *     *
87     * @param fileName the name of the file to open     * @param fileName the name of the file to open
88     * @exception FileNotFoundException if the fileName cannot be found     * @exception FileNotFoundException if the fileName cannot be found
# Line 90  public class JarFile extends ZipFile Line 94  public class JarFile extends ZipFile
94    }    }
95    
96    /**    /**
97     * Creates a new JarFile, tries to read the manifest and if the manifest     * Creates a new JarFile. If verify is true then all jar entries are
98     * exists and verify is true verfies it.     * verified (when a Manifest file for this JarFile exists). You need to
99       * actually open and read the complete jar entry
100       * (with <code>getInputStream()</code>) to check its signature.
101     *     *
102     * @param fileName the name of the file to open     * @param fileName the name of the file to open
103     * @param verify checks manifest and entries when true and a manifest     * @param verify checks manifest and entries when true and a manifest
# Line 103  public class JarFile extends ZipFile Line 109  public class JarFile extends ZipFile
109      FileNotFoundException, IOException      FileNotFoundException, IOException
110    {    {
111      super(fileName);      super(fileName);
     manifest = readManifest();  
     if (verify)  
       verify();  
112    }    }
113    
114    /**    /**
115     * Creates a new JarFile, tries to read the manifest and if the manifest     * Creates a new JarFile. All jar entries are verified (when a Manifest file
116     * exists verifies it.     * for this JarFile exists). You need to actually open and read the complete
117       * jar entry (with <code>getInputStream()</code>) to check its signature.
118     *     *
119     * @param file the file to open as a jar file     * @param file the file to open as a jar file
120     * @exception FileNotFoundException if the file does not exits     * @exception FileNotFoundException if the file does not exits
# Line 122  public class JarFile extends ZipFile Line 126  public class JarFile extends ZipFile
126    }    }
127    
128    /**    /**
129     * Creates a new JarFile, tries to read the manifest and if the manifest     * Creates a new JarFile. If verify is true then all jar entries are
130     * exists and verify is true verfies it.     * verified (when a Manifest file for this JarFile exists). You need to
131       * actually open and read the complete jar entry
132       * (with <code>getInputStream()</code>) to check its signature.
133     *     *
134     * @param file the file to open to open as a jar file     * @param file the file to open to open as a jar file
135     * @param verify checks manifest and entries when true and a manifest     * @param verify checks manifest and entries when true and a manifest
# Line 135  public class JarFile extends ZipFile Line 141  public class JarFile extends ZipFile
141      IOException      IOException
142    {    {
143      super(file);      super(file);
     manifest = readManifest();  
     if (verify)  
       verify();  
144    }    }
145    
146    /**    /**
147     * Creates a new JarFile with the indicated mode, tries to read the     * Creates a new JarFile with the indicated mode. If verify is true then
148       * all jar entries are verified (when a Manifest file for this JarFile
149       * exists). You need to actually open and read the complete jar entry
150       * (with <code>getInputStream()</code>) to check its signature.
151     * manifest and if the manifest exists and verify is true verfies it.     * manifest and if the manifest exists and verify is true verfies it.
152     *     *
153     * @param file the file to open to open as a jar file     * @param file the file to open to open as a jar file
# Line 159  public class JarFile extends ZipFile Line 165  public class JarFile extends ZipFile
165      FileNotFoundException, IOException, IllegalArgumentException      FileNotFoundException, IOException, IllegalArgumentException
166    {    {
167      super(file, mode);      super(file, mode);
     manifest = readManifest();  
     if (verify)  
       verify();  
168    }    }
169    
170    // Methods    // Methods
# Line 241  public class JarFile extends ZipFile Line 244  public class JarFile extends ZipFile
244      {      {
245        ZipEntry zip = (ZipEntry) entries.nextElement();        ZipEntry zip = (ZipEntry) entries.nextElement();
246        JarEntry jar = new JarEntry(zip);        JarEntry jar = new JarEntry(zip);
247          Manifest manifest;
248          try
249            {
250              manifest = getManifest();
251            }
252          catch (IOException ioe)
253            {
254              manifest = null;
255            }
256    
257        if (manifest != null)        if (manifest != null)
258          {          {
259            jar.attr = manifest.getAttributes(jar.getName());            jar.attr = manifest.getAttributes(jar.getName());
# Line 261  public class JarFile extends ZipFile Line 274  public class JarFile extends ZipFile
274      if (entry != null)      if (entry != null)
275        {        {
276          JarEntry jarEntry = new JarEntry(entry);          JarEntry jarEntry = new JarEntry(entry);
277            Manifest manifest;
278            try
279              {
280                manifest = getManifest();
281              }
282            catch (IOException ioe)
283              {
284                manifest = null;
285              }
286    
287          if (manifest != null)          if (manifest != null)
288            {            {
289              jarEntry.attr = manifest.getAttributes(name);              jarEntry.attr = manifest.getAttributes(name);
# Line 303  public class JarFile extends ZipFile Line 326  public class JarFile extends ZipFile
326     */     */
327    public Manifest getManifest() throws IOException    public Manifest getManifest() throws IOException
328    {    {
329        if (!manifestRead)
330          manifest = readManifest();
331    
332      return manifest;      return manifest;
333    }    }
334  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26