/** * Constructor. <b>Operation not supported.</b> * * @param in * Zip input stream to load. * @param access */ public ZipPackage(Stream in1, PackageAccess access) : base(access) { isStream = true; ZipInputStream zis = ZipHelper.OpenZipStream(in1); // TODO: ZipSecureFile //ThresholdInputStream zis = ZipHelper.OpenZipStream(in1); this.zipArchive = new ZipInputStreamZipEntrySource(zis); }
private bool isStream = false; // whether the file is passed in with stream, no means passed in with string path /** * Constructor. Creates a new ZipPackage. */ public ZipPackage() : base(defaultPackageAccess) { this.zipArchive = null; try { this.contentTypeManager = new ZipContentTypeManager(null, this); } catch (InvalidFormatException) { } }
/** * Constructor. Creates a new ZipPackage. */ public ZipPackage() : base(defaultPackageAccess) { this.zipArchive = null; try { this.contentTypeManager = new ZipContentTypeManager(null, this); } catch (InvalidFormatException e) { logger.Log(POILogger.WARN, "Could not parse ZipPackage", e); } }
/** * Constructor. Opens a Zip based Open XML document. * * @param path * The path of the file to open or create. * @param access * The package access mode. * @throws InvalidFormatException * If the content type part parsing encounters an error. */ public ZipPackage(string path, PackageAccess access) : base(access) { ZipFile zipFile = null; try { zipFile = ZipHelper.OpenZipFile(path); } catch (IOException e) { throw new InvalidOperationException( "Can't open the specified file: '" + path + "'", e); } this.zipArchive = new ZipFileZipEntrySource(zipFile); }
/** * Constructor. Opens a Zip based Open XML document. * * @param file * The file to open or create. * @param access * The package access mode. */ public ZipPackage(FileInfo file, PackageAccess access) : base(access) { ZipEntrySource ze; try { ZipFile zipFile = ZipHelper.OpenZipFile(file); ze = new ZipFileZipEntrySource(zipFile); } catch (IOException e) { // probably not happening with write access - not sure how to handle the default read-write access ... if (access == PackageAccess.WRITE) { throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e); } logger.Log(POILogger.ERROR, "Error in zip file " + file + " - falling back to stream processing (i.e. ignoring zip central directory)"); // some zips can't be opened via ZipFile in JDK6, as the central directory // contains either non-latin entries or the compression type can't be handled // the workaround is to iterate over the stream and not the directory FileStream fis = null; //ThresholdInputStream zis = null; ZipInputStream zis = null; try { fis = file.Create(); // TODO: ZipSecureFile // zis = ZipHelper.OpenZipStream(fis); zis = ZipHelper.OpenZipStream(fis); ze = new ZipInputStreamZipEntrySource(zis); } catch (IOException e2) { if (zis != null) { try { zis.Close(); } catch (IOException) { throw new InvalidOperationException("Can't open the specified file: '" + file + "'" + " and couldn't close the file input stream", e); } } else if (fis != null) { try { fis.Close(); } catch (IOException) { throw new InvalidOperationException("Can't open the specified file: '" + file + "'" + " and couldn't close the file input stream", e); } } throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e2); } } this.zipArchive = ze; }
/** * Constructor. Opens a Zip based Open XML document from * a custom ZipEntrySource, typically an open archive * from another system * * @param zipEntry * Zip data to load. * @param access * The package access mode. */ public ZipPackage(ZipEntrySource zipEntry, PackageAccess access) : base(access) { this.zipArchive = zipEntry; }
/** * Constructor. <b>Operation not supported.</b> * * @param in * Zip input stream to load. * @param access * @throws ArgumentException * If the specified input stream not an instance of * ZipInputStream. */ public ZipPackage(Stream filestream, PackageAccess access) : base(access) { isStream = true; this.zipArchive = new ZipInputStreamZipEntrySource(new ZipInputStream(filestream)); }