Exemplo n.º 1
0
        internal ZipFileInfo AddFile(string zipFileName, CompressionMethodEnum compressionMethod, DeflateOptionEnum deflateOption)
        {
            this.CheckDisposed();
            if (this._openAccess == FileAccess.Read)
            {
                throw new InvalidOperationException(SR.Get("CanNotWriteInReadOnlyMode"));
            }
            zipFileName = ZipIOBlockManager.ValidateNormalizeFileName(zipFileName);
            if ((compressionMethod != CompressionMethodEnum.Stored) && (compressionMethod != CompressionMethodEnum.Deflated))
            {
                throw new ArgumentOutOfRangeException("compressionMethod");
            }
            if ((deflateOption < DeflateOptionEnum.Normal) || ((deflateOption > DeflateOptionEnum.SuperFast) && (deflateOption != DeflateOptionEnum.None)))
            {
                throw new ArgumentOutOfRangeException("deflateOption");
            }
            if (this.FileExists(zipFileName))
            {
                throw new InvalidOperationException(SR.Get("AttemptedToCreateDuplicateFileName"));
            }
            ZipIOLocalFileBlock fileBlock = this._blockManager.CreateLocalFileBlock(zipFileName, compressionMethod, deflateOption);
            ZipFileInfo         info      = new ZipFileInfo(this, fileBlock);

            this.ZipFileInfoDictionary.Add(info.Name, info);
            return(info);
        }
Exemplo n.º 2
0
 internal void DeleteFile(string zipFileName)
 {
     this.CheckDisposed();
     if (this._openAccess == FileAccess.Read)
     {
         throw new InvalidOperationException(SR.Get("CanNotWriteInReadOnlyMode"));
     }
     zipFileName = ZipIOBlockManager.ValidateNormalizeFileName(zipFileName);
     if (this.FileExists(zipFileName))
     {
         ZipFileInfo file = this.GetFile(zipFileName);
         this.ZipFileInfoDictionary.Remove(zipFileName);
         this._blockManager.RemoveLocalFileBlock(file.LocalFileBlock);
     }
 }
Exemplo n.º 3
0
        internal ZipFileInfo GetFile(string zipFileName)
        {
            this.CheckDisposed();
            if (this._openAccess == FileAccess.Write)
            {
                throw new InvalidOperationException(SR.Get("CanNotReadInWriteOnlyMode"));
            }
            zipFileName = ZipIOBlockManager.ValidateNormalizeFileName(zipFileName);
            if (this.ZipFileInfoDictionary.Contains(zipFileName))
            {
                return((ZipFileInfo)this.ZipFileInfoDictionary[zipFileName]);
            }
            if (!this.FileExists(zipFileName))
            {
                throw new InvalidOperationException(SR.Get("FileDoesNotExists"));
            }
            ZipIOLocalFileBlock fileBlock = this._blockManager.LoadLocalFileBlock(zipFileName);
            ZipFileInfo         info      = new ZipFileInfo(this, fileBlock);

            this.ZipFileInfoDictionary.Add(info.Name, info);
            return(info);
        }