/// <summary> /// General initialization function. /// </summary> /// <param name="archiveFullName">The archive file name.</param> private void Init(string archiveFullName) { _fileName = archiveFullName; bool isExecutable; _format = FileChecker.CheckSignature(archiveFullName, out _offset, out isExecutable); PreserveDirectoryStructure = true; SevenZipLibraryManager.LoadLibrary(this, _format); try { _archive = SevenZipLibraryManager.InArchive(_format, this); } catch (SevenZipLibraryException) { SevenZipLibraryManager.FreeLibrary(this, _format); throw; } if (isExecutable && _format != InArchiveFormat.PE) { if (!Check()) { CommonDispose(); _format = InArchiveFormat.PE; SevenZipLibraryManager.LoadLibrary(this, _format); try { _archive = SevenZipLibraryManager.InArchive(_format, this); } catch (SevenZipLibraryException) { SevenZipLibraryManager.FreeLibrary(this, _format); throw; } } } }
public SevenZipFileSystem(IInArchive archive, IFileName rootName, IFileObject parentLayer, FileSystemOptions fileSystemOptions) : base(rootName, parentLayer, fileSystemOptions) { this.archive = archive; if (parentLayer.FileSystem is LocalFileSystem || parentLayer.Content.Size > 1048576) { file = parentLayer.FileSystem.replicateFile(parentLayer, Selectors.SELECT_SELF); } }
public void Close() { if (inArchive != null) { inArchive.Close(); inArchive = null; } if (stream != null && stream is IDisposable) { ((IDisposable)stream).Dispose(); } stream = null; }
protected void Dispose(bool disposing) { if (this.FArchive != null) { if (disposing) { this.Archive.Close(); } Marshal.FinalReleaseComObject(this.FArchive); this.FArchive = null; } if (this.FArchivePtr != IntPtr.Zero) { Marshal.Release(this.FArchivePtr); this.FArchivePtr = IntPtr.Zero; } if (this.ArchiveStreamWrapper != null) { this.ArchiveStreamWrapper.Dispose(); this.ArchiveStreamWrapper = null; } }
/* ----------------------------------------------------------------- */ /// /// ReadOnlyArchiveCollection /// /// <summary> /// オブジェクトを初期化します。 /// </summary> /// /// <param name="archive">実装オブジェクト</param> /// <param name="src">圧縮ファイルのパス</param> /// <param name="password">パスワード取得用オブジェクト</param> /// <param name="io">入出力用のオブジェクト</param> /// /* ----------------------------------------------------------------- */ public ReadOnlyArchiveList(IInArchive archive, string src, PasswordQuery password, IO io) { Source = src; _controller = new ArchiveItemController(archive, password, io); }
internal Variant(IInArchive Archive, uint FileNumber, ItemPropId Id) { Archive.GetProperty(FileNumber, Id, ref variant); }
/// <summary> /// Initializes a new instance of the ArchiveExtractCallback class /// </summary> /// <param name="archive">IInArchive interface for the archive</param> /// <param name="directory">Directory where files are to be unpacked to</param> /// <param name="filesCount">The archive files count</param> /// <param name="password">Password for the archive</param> /// <param name="extractor">The owner of the callback</param> /// <param name="actualIndexes">The list of actual indexes (solid archives support)</param> /// <param name="directoryStructure">The value indicating whether to preserve directory structure of extracted files.</param> public ArchiveExtractCallback(IInArchive archive, string directory, int filesCount, bool directoryStructure, List<uint> actualIndexes, string password, SevenZipExtractor extractor) : base(password) { Init(archive, directory, filesCount, directoryStructure, actualIndexes, extractor); }
private void InternalOpen(IArchiveOpenCallback callback, Guid format) { var Interface = typeof(IInArchive).GUID; object result; if (CpuInfo.IsX64) { SafeNativeMethods.CreateObject_64(ref format, ref Interface, out result); } else { SafeNativeMethods.CreateObject_32(ref format, ref Interface, out result); } if (result == null) { throw new COMException("Cannot create Archive"); } inArchive = result as IInArchive; var sp = (ulong)(1 << 23); inArchive.Open(stream, ref sp, callback); }
private void Init(IInArchive archive, Stream stream, int filesCount, uint fileIndex, SevenZipExtractor extractor) { CommonInit(archive, filesCount, extractor); _fileStream = new OutStreamWrapper(stream, false); _fileStream.BytesWritten += IntEventArgsHandler; _fileIndex = fileIndex; }
private void CommonInit(IInArchive archive, int filesCount, SevenZipExtractor extractor) { _archive = archive; _filesCount = filesCount; _fakeStream = new FakeOutStreamWrapper(); _fakeStream.BytesWritten += IntEventArgsHandler; _extractor = extractor; #if !WINCE GC.AddMemoryPressure(MEMORY_PRESSURE); #endif }
/// <summary> /// Initializes a new instance of the ArchiveExtractCallback class /// </summary> /// <param name="archive">IInArchive interface for the archive</param> /// <param name="stream">The stream where files are to be unpacked to</param> /// <param name="filesCount">The archive files count</param> /// <param name="fileIndex">The file index for the stream</param> /// <param name="password">Password for the archive</param> /// <param name="extractor">The owner of the callback</param> public ArchiveExtractCallback(IInArchive archive, Stream stream, int filesCount, uint fileIndex, string password, SevenZipExtractor extractor) : base(password) { Init(archive, stream, filesCount, fileIndex, extractor); }
private void Init(IInArchive archive, string directory, int filesCount, bool directoryStructure, List<uint> actualIndexes, SevenZipExtractor extractor) { CommonInit(archive, filesCount, extractor); _directory = directory; _actualIndexes = actualIndexes; _directoryStructure = directoryStructure; if (!directory.EndsWith("" + Path.DirectorySeparatorChar, StringComparison.CurrentCulture)) { _directory += Path.DirectorySeparatorChar; } }
/// <summary> /// General initialization function. /// </summary> /// <param name="stream">The stream to read the archive from.</param> private void Init(Stream stream) { ValidateStream(stream); bool isExecutable = false; if ((int)_format == -1) { _format = FileChecker.CheckSignature(stream, out _offset, out isExecutable); } PreserveDirectoryStructure = true; SevenZipLibraryManager.LoadLibrary(this, _format); try { _inStream = new ArchiveEmulationStreamProxy(stream, _offset); _packedSize = stream.Length; _archive = SevenZipLibraryManager.InArchive(_format, this); } catch (SevenZipLibraryException) { SevenZipLibraryManager.FreeLibrary(this, _format); throw; } if (isExecutable && _format != InArchiveFormat.PE) { if (!Check()) { CommonDispose(); _format = InArchiveFormat.PE; try { _inStream = new ArchiveEmulationStreamProxy(stream, _offset); _packedSize = stream.Length; _archive = SevenZipLibraryManager.InArchive(_format, this); } catch (SevenZipLibraryException) { SevenZipLibraryManager.FreeLibrary(this, _format); throw; } } } }
/* ----------------------------------------------------------------- */ /// /// ArchiveItemController /// /// <summary> /// Initializes a new instance of the ArchvieItemController class /// with the specified arguments. /// </summary> /// /// <param name="archive">7-zip module.</param> /// <param name="password">Query to get password.</param> /// <param name="io">I/O handler.</param> /// /* ----------------------------------------------------------------- */ public ArchiveItemController(IInArchive archive, PasswordQuery password, IO io) { Archive = archive; Password = password; IO = io; }
internal Variant(IInArchive Archive, ItemPropId Id) { Archive.GetArchiveProperty(Id, ref variant); }
public ArchiveExtractCallback(IInArchive archive, Stream stream, int filesCount, uint fileIndex, SevenZipExtractor extractor) { this.Init(archive, stream, filesCount, fileIndex, extractor); }
public ArchiveExtractCallback(IInArchive archive, string directory, int filesCount, List <uint> actualIndexes, string password, SevenZipExtractor extractor) : base(password) { this.Init(archive, directory, filesCount, actualIndexes, extractor); }
const int MEMORY_PRESSURE = 64 * 1024 * 1024; //64mb seems to be the maximum value #endif #region Constructors /// <summary> /// Initializes a new instance of the ArchiveExtractCallback class /// </summary> /// <param name="archive">IInArchive interface for the archive</param> /// <param name="directory">Directory where files are to be unpacked to</param> /// <param name="filesCount">The archive files count</param>' /// <param name="extractor">The owner of the callback</param> /// <param name="actualIndexes">The list of actual indexes (solid archives support)</param> /// <param name="directoryStructure">The value indicating whether to preserve directory structure of extracted files.</param> public ArchiveExtractCallback(IInArchive archive, string directory, int filesCount, bool directoryStructure, List <uint> actualIndexes, SevenZipExtractor extractor) { Init(archive, directory, filesCount, directoryStructure, actualIndexes, extractor); }
private void CommonDispose() { if (_opened) { try { if (_archive != null) { _archive.Close(); } } catch (Exception) { } } _archive = null; _archiveFileData = null; _archiveProperties = null; _archiveFileInfoCollection = null; _inStream = null; if (_openCallback != null) { try { _openCallback.Dispose(); } catch (ObjectDisposedException) { } _openCallback = null; } if (_archiveStream != null) { if (_archiveStream is IDisposable) { try { if (_archiveStream is DisposeVariableWrapper) { (_archiveStream as DisposeVariableWrapper).DisposeStream = true; } (_archiveStream as IDisposable).Dispose(); } catch (ObjectDisposedException) { } _archiveStream = null; } } SevenZipLibraryManager.FreeLibrary(this, _format); }
/// <summary> /// Initializes a new instance of the ArchiveExtractCallback class /// </summary> /// <param name="archive">IInArchive interface for the archive</param> /// <param name="stream">The stream where files are to be unpacked to</param> /// <param name="filesCount">The archive files count</param> /// <param name="fileIndex">The file index for the stream</param> /// <param name="extractor">The owner of the callback</param> public ArchiveExtractCallback(IInArchive archive, Stream stream, int filesCount, uint fileIndex, SevenZipExtractor extractor) { Init(archive, stream, filesCount, fileIndex, extractor); }