예제 #1
0
        private T GetProperty <T>(uint fileIndex, ItemPropId name)
        {
            PropVariant propVariant = new PropVariant();

            this.archive.GetProperty(fileIndex, name, ref propVariant);
            object value = propVariant.GetObject();

            if (propVariant.VarType == VarEnum.VT_EMPTY)
            {
                propVariant.Clear();
                return(default(T));
            }

            propVariant.Clear();

            if (value == null)
            {
                return(default(T));
            }

            Type type           = typeof(T);
            bool isNullable     = type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>);
            Type underlyingType = isNullable ? Nullable.GetUnderlyingType(type) : type;

            T result = (T)Convert.ChangeType(value.ToString(), underlyingType);

            return(result);
        }
예제 #2
0
        private T GetProperty <T>(uint fileIndex, ItemPropId name)
        {
            PropVariant propVariant = new PropVariant();

            this.archive.GetProperty(fileIndex, name, ref propVariant);
            return((T)propVariant.GetObject());
        }
예제 #3
0
            public void GetProperty(int index, ItemPropId propID, IntPtr value)
            {
                FileInfo info = this.FileList[index];

                switch (propID)
                {
                case ItemPropId.kpidPath:
                    Marshal.GetNativeVariantForObject(Path.GetFileName(info.FullName), value);
                    return;

                case ItemPropId.kpidIsFolder:
                case ItemPropId.kpidIsAnti:
                    Marshal.GetNativeVariantForObject(false, value);
                    return;

                case ItemPropId.kpidSize:
                    Marshal.GetNativeVariantForObject((ulong)info.Length, value);
                    return;

                case ItemPropId.kpidCreationTime:
                    this.GetTimeProperty(info.CreationTime, value);
                    return;

                case ItemPropId.kpidLastAccessTime:
                    this.GetTimeProperty(info.LastAccessTime, value);
                    return;

                case ItemPropId.kpidLastWriteTime:
                    this.GetTimeProperty(info.LastWriteTime, value);
                    return;
                }
                Marshal.WriteInt16(value, (short)0);
            }
예제 #4
0
 public int GetProperty(ItemPropId propId, ref PropVariant value)
 {
     switch (propId)
     {
         case ItemPropId.Name:
             value.VarType = VarEnum.VT_BSTR;
             value.Value = Marshal.StringToBSTR(_fileInfo.FullName);
             break;
         case ItemPropId.IsDirectory:
             value.VarType = VarEnum.VT_BOOL;
             value.UInt64Value = (byte) (_fileInfo.Attributes & FileAttributes.Directory);
             break;
         case ItemPropId.Size:
             value.VarType = VarEnum.VT_UI8;
             value.UInt64Value = (UInt64) _fileInfo.Length;
             break;
         case ItemPropId.Attributes:
             value.VarType = VarEnum.VT_UI4;
             value.UInt32Value = (uint) _fileInfo.Attributes;
             break;
         case ItemPropId.CreationTime:
             value.VarType = VarEnum.VT_FILETIME;
             value.Int64Value = _fileInfo.CreationTime.ToFileTime();
             break;
         case ItemPropId.LastAccessTime:
             value.VarType = VarEnum.VT_FILETIME;
             value.Int64Value = _fileInfo.LastAccessTime.ToFileTime();
             break;
         case ItemPropId.LastWriteTime:
             value.VarType = VarEnum.VT_FILETIME;
             value.Int64Value = _fileInfo.LastWriteTime.ToFileTime();
             break;
     }
     return 0;
 }
 public void GetProperty(ItemPropId propID, IntPtr value)
 {
     if (propID == ItemPropId.kpidName)
     {
         if (this.IsRarArchive)
         {
             Match match = new Regex(@"^(?<name>.+?)\.((?<a>part(?<num>\d{1,2})\.rar)|(?<b>r(?<num>\d{2}))|rar)$", RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase).Match(this.ArchiveFileName);
             if (match.Success)
             {
                 if (match.Groups["a"].Success)
                 {
                     this.NameFormat = match.Groups["name"].Value + ".part{0}.rar";
                     this.NameCounter = Convert.ToInt32(match.Groups["num"].Value);
                 }
                 else
                 {
                     this.NameFormat = match.Groups["name"].Value + ".r{0:00}";
                     if (match.Groups["b"].Success)
                     {
                         this.NameCounter = Convert.ToInt32(match.Groups["num"].Value);
                     }
                     else
                     {
                         this.NameCounter = -1;
                     }
                 }
             }
         }
         Marshal.GetNativeVariantForObject(this.ArchiveFileName, value);
     }
 }
예제 #6
0
        public int GetProperty(ItemPropId propID, ref PropVariant value)
        {
            value.Clear();

            if (_subArchiveMode)
            {
                if (propID == ItemPropId.Name)
                {
                    value.SetBString(_subArchiveName);
                }
            }
            else
            {
                switch (propID)
                {
                case ItemPropId.Name:
                    if (!_streamMode)
                    {
                        value.SetBString(Path.GetFileName(_fileName));
                    }
                    break;

                case ItemPropId.IsDirectory:
                    value.SetBool(_streamMode ? false : (byte)(new FileInfo(_fileName).Attributes & FileAttributes.Directory) != 0);
                    break;

                case ItemPropId.Size:
                    value.SetULong((ulong)_currentVolumeSize);
                    break;

                case ItemPropId.Attributes:
                    value.SetUInt(_streamMode ? (uint)0 : (uint)new FileInfo(_fileName).Attributes);
                    break;

                case ItemPropId.CreationTime:
                    if (!_streamMode)
                    {
                        value.SetDateTime(new FileInfo(_fileName).CreationTime);
                    }
                    break;

                case ItemPropId.LastAccessTime:
                    if (!_streamMode)
                    {
                        value.SetDateTime(new FileInfo(_fileName).LastAccessTime);
                    }
                    break;

                case ItemPropId.LastWriteTime:
                    if (!_streamMode)
                    {
                        value.SetDateTime(new FileInfo(_fileName).LastWriteTime);
                    }
                    break;
                }
            }
            return(HRESULT.S_OK);
        }
        /* ----------------------------------------------------------------- */
        ///
        /// Get
        ///
        /// <summary>
        /// Gets information corresponding to the specified ID.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public static T Get <T>(this IInArchive src, int index, ItemPropId pid)
        {
            var var = new PropVariant();

            src.GetProperty((uint)index, pid, ref var);

            var obj = var.Object;

            return(obj is T dest ? dest : default);
예제 #8
0
        /* ----------------------------------------------------------------- */
        ///
        /// Get
        ///
        /// <summary>
        /// Gets information corresponding to the specified ID.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private T Get <T>(int index, ItemPropId pid)
        {
            var var = new PropVariant();

            Archive.GetProperty((uint)index, pid, ref var);

            var obj = var.Object;

            return(obj is T dest ? dest : default);
예제 #9
0
        private T GetProperty <T>(uint fileIndex, ItemPropId name, Func <object, T> convert)
        {
            PropVariant propVariant = new PropVariant();

            this.archive7z.GetProperty((uint)fileIndex, name, ref propVariant);
            var value = propVariant.GetValue(convert);

            propVariant.Clear();
            return(value);
        }
예제 #10
0
        /* ----------------------------------------------------------------- */
        ///
        /// Get
        ///
        /// <summary>
        /// 情報を取得します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private T Get <T>(string src, ItemPropId pid)
        {
            var var = new PropVariant();

            _archive.GetProperty((uint)Index, pid, ref var);

            var obj = var.Object;

            return((obj != null && obj is T) ? (T)obj : default(T));
        }
예제 #11
0
 private T GetPropertySafe <T>(uint fileIndex, ItemPropId name)
 {
     try
     {
         return(this.GetProperty <T>(fileIndex, name));
     }
     catch (InvalidCastException)
     {
         return(default(T));
     }
 }
예제 #12
0
 /* ----------------------------------------------------------------- */
 ///
 /// GetProperty
 ///
 /// <summary>
 /// 圧縮ファイルのプロパティを取得します。
 /// </summary>
 ///
 /// <param name="pid">プロパティ ID</param>
 /// <param name="value">プロパティ ID に対応する値</param>
 ///
 /// <returns>OperationResult</returns>
 ///
 /* ----------------------------------------------------------------- */
 public int GetProperty(ItemPropId pid, ref PropVariant value)
 {
     if (pid == ItemPropId.Name)
     {
         value.Set(IO.Get(Source).FullName);
     }
     else
     {
         value.Clear();
     }
     return(Invoke(() => (int)Result));
 }
 internal ArchiveProperty(ItemPropId property, string name, object value)
     : this()
 {
     this.Property = property;
     this.Value    = value;
     if (name != null)
     {
         this.PropertyName = name;
     }
     else if (_propertyNames.ContainsKey(property))
     {
         this.PropertyName = _propertyNames[property];
     }
 }
예제 #14
0
        private T GetProperty <T>(uint fileIndex, ItemPropId name)
        {
            PropVariant propVariant = new PropVariant();

            this.archive.GetProperty(fileIndex, name, ref propVariant);

            T result = propVariant.VarType != VarEnum.VT_EMPTY
                ? (T)propVariant.GetObject()
                : default(T);

            propVariant.Clear();

            return(result);
        }
        public int GetProperty(ItemPropId propId, ref PropVariant value)
        {
            if (_fileInfo == null)
            {
                // We are likely opening an archive from a Stream, and no file or _fileInfo exists.
                return(0);
            }

            switch (propId)
            {
            case ItemPropId.Name:
                value.VarType = VarEnum.VT_BSTR;
                value.Value   = Marshal.StringToBSTR(_fileInfo.FullName);
                break;

            case ItemPropId.IsDirectory:
                value.VarType     = VarEnum.VT_BOOL;
                value.UInt64Value = (byte)(_fileInfo.Attributes & FileAttributes.Directory);
                break;

            case ItemPropId.Size:
                value.VarType     = VarEnum.VT_UI8;
                value.UInt64Value = (UInt64)_fileInfo.Length;
                break;

            case ItemPropId.Attributes:
                value.VarType     = VarEnum.VT_UI4;
                value.UInt32Value = (uint)_fileInfo.Attributes;
                break;

            case ItemPropId.CreationTime:
                value.VarType    = VarEnum.VT_FILETIME;
                value.Int64Value = _fileInfo.CreationTime.ToFileTime();
                break;

            case ItemPropId.LastAccessTime:
                value.VarType    = VarEnum.VT_FILETIME;
                value.Int64Value = _fileInfo.LastAccessTime.ToFileTime();
                break;

            case ItemPropId.LastWriteTime:
                value.VarType    = VarEnum.VT_FILETIME;
                value.Int64Value = _fileInfo.LastWriteTime.ToFileTime();
                break;
            }

            return(0);
        }
        /* ----------------------------------------------------------------- */
        ///
        /// GetProperty
        ///
        /// <summary>
        /// 各種プロパティを取得します。
        /// </summary>
        ///
        /// <param name="index">圧縮ファイル中のインデックス</param>
        /// <param name="pid">プロパティの種類</param>
        /// <param name="value">プロパティの内容</param>
        ///
        /// <returns>OperationResult</returns>
        ///
        /* ----------------------------------------------------------------- */
        public int GetProperty(uint index, ItemPropId pid, ref PropVariant value)
        {
            var src = GetItem(index);

            switch (pid)
            {
            case ItemPropId.Path:
                value.Set(src.PathInArchive);
                break;

            case ItemPropId.Attributes:
                value.Set((uint)src.Attributes);
                break;

            case ItemPropId.IsDirectory:
                value.Set(src.IsDirectory);
                break;

            case ItemPropId.IsAnti:
                value.Set(false);
                break;

            case ItemPropId.CreationTime:
                value.Set(src.CreationTime);
                break;

            case ItemPropId.LastAccessTime:
                value.Set(src.LastAccessTime);
                break;

            case ItemPropId.LastWriteTime:
                value.Set(src.LastWriteTime);
                break;

            case ItemPropId.Size:
                value.Set((ulong)src.Length);
                break;

            default:
                this.LogDebug($"Unknown\tPid:{pid}");
                value.Clear();
                break;
            }

            return(Invoke(() => (int)Result));
        }
예제 #17
0
        void IArchiveOpenVolumeCallback.GetProperty(ItemPropId propID, ref PropVariant rv)
        {
            switch (propID)
            {
            case ItemPropId.Name:
                rv.type            = VarEnum.VT_BSTR;
                rv.union.bstrValue = Marshal.StringToBSTR(archive.FullName);
                return;

            case ItemPropId.Size:
                rv.type           = VarEnum.VT_UI8;
                rv.union.ui8Value = (ulong)current.Length;
                return;

            default:
                throw new NotImplementedException();
            }
        }
        public int GetProperty(ItemPropId propId, ref PropVariant value)
        {
            switch (propId)
            {
            case ItemPropId.Name:
                value.VarType = VarEnum.VT_BSTR;
                value.Value   = Marshal.StringToBSTR(this._FileInfo.FullName);
                break;

            case ItemPropId.IsDirectory:
                value.VarType     = VarEnum.VT_BOOL;
                value.UInt64Value = (ulong)(byte)(this._FileInfo.Attributes & FileAttributes.Directory);
                break;

            case ItemPropId.Size:
                value.VarType     = VarEnum.VT_UI8;
                value.UInt64Value = (ulong)this._FileInfo.Length;
                break;

            case ItemPropId.Attributes:
                value.VarType     = VarEnum.VT_UI4;
                value.UInt32Value = (uint)this._FileInfo.Attributes;
                break;

            case ItemPropId.CreationTime:
                value.VarType    = VarEnum.VT_FILETIME;
                value.Int64Value = this._FileInfo.CreationTime.ToFileTime();
                break;

            case ItemPropId.LastAccessTime:
                value.VarType    = VarEnum.VT_FILETIME;
                value.Int64Value = this._FileInfo.LastAccessTime.ToFileTime();
                break;

            case ItemPropId.LastWriteTime:
                value.VarType    = VarEnum.VT_FILETIME;
                value.Int64Value = this._FileInfo.LastWriteTime.ToFileTime();
                break;
            }
            return(0);
        }
예제 #19
0
            public void GetProperty(int index, ItemPropId propID, IntPtr value)
            {
                FileInfo Source = FileList[index];

                switch (propID)
                {
                case ItemPropId.kpidPath:
                    Marshal.GetNativeVariantForObject(Path.GetFileName(Source.FullName), value);
                    break;

                case ItemPropId.kpidIsFolder:
                case ItemPropId.kpidIsAnti:
                    Marshal.GetNativeVariantForObject(false, value);
                    break;

                //case ItemPropId.kpidAttributes:
                //  Marshal.WriteInt16(value, (short)VarEnum.VT_EMPTY);
                //  break;
                case ItemPropId.kpidCreationTime:
                    GetTimeProperty(Source.CreationTime, value);
                    break;

                case ItemPropId.kpidLastAccessTime:
                    GetTimeProperty(Source.LastAccessTime, value);
                    break;

                case ItemPropId.kpidLastWriteTime:
                    GetTimeProperty(Source.LastWriteTime, value);
                    break;

                case ItemPropId.kpidSize:
                    Marshal.GetNativeVariantForObject((ulong)Source.Length, value);
                    break;

                default:
                    Marshal.WriteInt16(value, (short)VarEnum.VT_EMPTY);
                    break;
                }
            }
예제 #20
0
 void IArchiveOpenVolumeCallback.GetProperty(ItemPropId propID, ref PropVariant rv)
 {
     (owner as IArchiveOpenVolumeCallback).GetProperty(propID, ref rv);
 }
 public void GetProperty(int index, ItemPropId propID, IntPtr value)
 {
     FileInfo Source = FileList[index];
     switch (propID)
     {
       case ItemPropId.kpidPath:
     Marshal.GetNativeVariantForObject(Path.GetFileName(Source.FullName), value);
     break;
       case ItemPropId.kpidIsFolder:
       case ItemPropId.kpidIsAnti:
     Marshal.GetNativeVariantForObject(false, value);
     break;
       //case ItemPropId.kpidAttributes:
       //  Marshal.WriteInt16(value, (short)VarEnum.VT_EMPTY);
       //  break;
       case ItemPropId.kpidCreationTime:
     GetTimeProperty(Source.CreationTime, value);
     break;
       case ItemPropId.kpidLastAccessTime:
     GetTimeProperty(Source.LastAccessTime, value);
     break;
       case ItemPropId.kpidLastWriteTime:
     GetTimeProperty(Source.LastWriteTime, value);
     break;
       case ItemPropId.kpidSize:
     Marshal.GetNativeVariantForObject((ulong)Source.Length, value);
     break;
       default:
     Marshal.WriteInt16(value, (short)VarEnum.VT_EMPTY);
     break;
     }
 }
예제 #22
0
 public void GetPropertyInfo(UInt32 index, out string name, out ItemPropId propID, out ushort varType)
 {
     inArchive.GetPropertyInfo(index, out name, out propID, out varType);
 }
예제 #23
0
 public Variant GetProperty(UInt32 Index, ItemPropId propId)
 {
     return new Variant(this, Index, propId);
 }
예제 #24
0
 public Variant GetArchiveProperty(ItemPropId propId)
 {
     return new Variant(this, propId);
 }
예제 #25
0
 internal Variant(IInArchive Archive, ItemPropId Id)
 {
     Archive.GetArchiveProperty(Id, ref variant);
 }
예제 #26
0
 void IArchiveOpenVolumeCallback.GetProperty(ItemPropId propID, ref PropVariant rv)
 {
     switch (propID) {
     case ItemPropId.Name:
       rv.type = VarEnum.VT_BSTR;
       rv.union.bstrValue = Marshal.StringToBSTR(archive.FullName);
       return;
     case ItemPropId.Size:
       rv.type = VarEnum.VT_UI8;
       rv.union.ui8Value = (ulong)current.Length;
       return;
     default:
       throw new NotImplementedException();
       }
 }
 private object GetProperty(ItemPropId PropId)
 {
     object obj2 = null;
     if ((this.CachedProperties == null) || !this.CachedProperties.TryGetValue(PropId, out obj2))
     {
         try
         {
             PropVariant variant = new PropVariant();
             try
             {
                 this.Context.GetProperty(this.Index, PropId, ref variant);
                 obj2 = variant.Value;
             }
             finally
             {
                 variant.Clear();
             }
             if (this.CachedProperties == null)
             {
                 this.CachedProperties = new Dictionary<ItemPropId, object>();
             }
             this.CachedProperties[PropId] = obj2;
         }
         catch (Exception exception)
         {
             exception.Data["SevenZip_ItemPropId"] = PropId;
             throw;
         }
     }
     return obj2;
 }
예제 #28
0
 public Variant GetArchiveProperty(ItemPropId propId)
 {
     return(new Variant(this, propId));
 }
예제 #29
0
        public int GetProperty(uint index, ItemPropId propID, ref PropVariant value)
        {
            index -= _indexOffset;
            string val = null;

            FileInfo fileInfo = null;

            if (_files != null && _files.Length > index)
            {
                fileInfo = _files[index];
            }
            else if (_streamFileInfos != null && _streamFileInfos.Length > index)
            {
                fileInfo = _streamFileInfos[index];
            }

            try
            {
                switch (propID)
                {
                case ItemPropId.IsAnti:
                    value.VarType     = VarEnum.VT_BOOL;
                    value.UInt64Value = 0;
                    break;

                case ItemPropId.SourcePath:
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (fileInfo != null)
                        {
                            value.VarType = VarEnum.VT_BSTR;
                            val           = fileInfo.FullName;
                            value.Value   = Marshal.StringToBSTR(val);
                        }
                    }
                    break;

                case ItemPropId.Path:
                    #region Path

                    value.VarType = VarEnum.VT_BSTR;
                    val           = DefaultItemName;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (_files == null)
                        {
                            if (_entries != null)
                            {
                                val = _entries[index];
                            }
                        }
                        else
                        {
                            if (_altNames != null && _altNames[index] != null)
                            {
                                val = _altNames[index];
                            }
                            else if (_directoryStructure && fileInfo != null)
                            {
                                if (_rootLength > 0)
                                {
                                    val = index + fileInfo.FullName.Substring(_rootLength);
                                }
                                else
                                {
                                    val = fileInfo.FullName[0] + fileInfo.FullName.Substring(2);
                                }
                            }
                            else if (fileInfo != null)
                            {
                                val = fileInfo.FullName;
                            }
                        }
                    }
                    else
                    {
                        val = _updateData.FileNamesToModify[(int)index];
                    }
                    value.Value = Marshal.StringToBSTR(val);
                    #endregion
                    break;

                case ItemPropId.IsDirectory:
                    value.VarType = VarEnum.VT_BOOL;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (_files == null)
                        {
                            if (_streams == null)
                            {
                                value.UInt64Value = 0;
                            }
                            else
                            {
                                value.UInt64Value = (ulong)(_streams[index] == null ? 1 : 0);
                            }
                        }
                        else
                        {
                            value.UInt64Value = (byte)(_files[index].Attributes & FileAttributes.Directory);
                        }
                    }
                    else
                    {
                        value.UInt64Value = Convert.ToUInt64(_updateData.ArchiveFileData[(int)index].IsDirectory);
                    }
                    break;

                case ItemPropId.Size:
                    #region Size

                    value.VarType = VarEnum.VT_UI8;
                    UInt64 size;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (_files == null)
                        {
                            if (_streams == null)
                            {
                                size = _bytesCount > 0 ? (ulong)_bytesCount : 0;
                            }
                            else if (fileInfo != null)
                            {
                                size = (ulong)fileInfo.Length;
                            }
                            else
                            {
                                size = (ulong)(_streams[index] == null? 0 : _streams[index].Length);
                            }
                        }
                        else
                        {
                            size = (fileInfo.Attributes & FileAttributes.Directory) == 0
                                           ? (ulong)fileInfo.Length
                                           : 0;
                        }
                    }
                    else
                    {
                        size = _updateData.ArchiveFileData[(int)index].Size;
                    }
                    value.UInt64Value = size;

                    #endregion
                    break;

                case ItemPropId.Attributes:
                    value.VarType = VarEnum.VT_UI4;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (fileInfo != null)
                        {
                            value.UInt32Value = (uint)fileInfo.Attributes;
                        }
                        else if (_files == null)
                        {
                            if (_streams == null)
                            {
                                value.UInt32Value = (uint)FileAttributes.Normal;
                            }
                            else
                            {
                                value.UInt32Value = (uint)(_streams[index] == null ? FileAttributes.Directory : FileAttributes.Normal);
                            }
                        }
                    }
                    else
                    {
                        value.UInt32Value = _updateData.ArchiveFileData[(int)index].Attributes;
                    }
                    break;

                    #region Times
                case ItemPropId.CreationTime:
                    value.VarType = VarEnum.VT_FILETIME;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        value.Int64Value = fileInfo == null
                                               ? DateTime.Now.ToFileTime()
                                               : fileInfo.CreationTime.ToFileTime();
                    }
                    else
                    {
                        value.Int64Value = _updateData.ArchiveFileData[(int)index].CreationTime.ToFileTime();
                    }
                    break;

                case ItemPropId.LastAccessTime:
                    value.VarType = VarEnum.VT_FILETIME;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        value.Int64Value = fileInfo == null
                                               ? DateTime.Now.ToFileTime()
                                               : fileInfo.LastAccessTime.ToFileTime();
                    }
                    else
                    {
                        value.Int64Value = _updateData.ArchiveFileData[(int)index].LastAccessTime.ToFileTime();
                    }
                    break;

                case ItemPropId.LastWriteTime:
                    value.VarType = VarEnum.VT_FILETIME;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        value.Int64Value = fileInfo == null
                                               ? DateTime.Now.ToFileTime()
                                               : fileInfo.LastWriteTime.ToFileTime();
                    }
                    else
                    {
                        value.Int64Value = _updateData.ArchiveFileData[(int)index].LastWriteTime.ToFileTime();
                    }
                    break;

                    #endregion
                case ItemPropId.Extension:
                    #region Extension

                    value.VarType = VarEnum.VT_BSTR;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        try
                        {
                            val = fileInfo != null
                                      ? fileInfo.Extension.Substring(1)
                                      : _entries == null
                                          ? ""
                                          : Path.GetExtension(_entries[index]);

                            value.Value = Marshal.StringToBSTR(val);
                        }
                        catch (ArgumentException)
                        {
                            value.Value = Marshal.StringToBSTR("");
                        }
                    }
                    else
                    {
                        val         = Path.GetExtension(_updateData.ArchiveFileData[(int)index].FileName);
                        value.Value = Marshal.StringToBSTR(val);
                    }

                    #endregion
                    break;
                }
            }
            catch (Exception e)
            {
                AddException(e);
            }
            return(0);
        }
예제 #30
0
 internal Variant(IInArchive Archive, uint FileNumber, ItemPropId Id)
 {
     Archive.GetProperty(FileNumber, Id, ref variant);
 }
예제 #31
0
 internal Variant(IInArchive Archive, ItemPropId Id)
 {
     Archive.GetArchiveProperty(Id, ref variant);
 }
 public void GetProperty(int index, ItemPropId propID, IntPtr value)
 {
 }
 private object GetSize(ItemPropId PropId)
 {
     object property = this.GetProperty(PropId);
     if (property != null)
     {
         return Convert.ToInt64(property);
     }
     return null;
 }
예제 #34
0
        public int GetProperty(ItemPropId propID, ref PropVariant value)
        {
            value.Clear();

            if (_subArchiveMode)
            {
                if (propID == ItemPropId.Name)
                {
                    value.SetBString(_subArchiveName);
                }
            }
            else
            {
                switch (propID)
                {
                    case ItemPropId.Name:
                        if (!_streamMode)
                        {
                            value.SetBString(Path.GetFileName(_fileName));
                        }
                        break;
                    case ItemPropId.IsDirectory:
                        value.SetBool(_streamMode ? false : (byte)(new FileInfo(_fileName).Attributes & FileAttributes.Directory) != 0);
                        break;
                    case ItemPropId.Size:
                        value.SetULong((ulong)_currentVolumeSize);
                        break;
                    case ItemPropId.Attributes:
                        value.SetUInt(_streamMode ? (uint)0 : (uint)new FileInfo(_fileName).Attributes);
                        break;
                    case ItemPropId.CreationTime:
                        if (!_streamMode)
                        {
                            value.SetDateTime(new FileInfo(_fileName).CreationTime);
                        }
                        break;
                    case ItemPropId.LastAccessTime:
                        if (!_streamMode)
                        {
                            value.SetDateTime(new FileInfo(_fileName).LastAccessTime);
                        }
                        break;
                    case ItemPropId.LastWriteTime:
                        if (!_streamMode)
                        {
                            value.SetDateTime(new FileInfo(_fileName).LastWriteTime);
                        }
                        break;
                }
            }
            return HRESULT.S_OK;
        }
예제 #35
0
 public void GetProperty(UInt32 index, ItemPropId propID, ref PropVariant value)
 {
     inArchive.GetProperty(index, propID, ref value);
 }
 public void GetPropertyInfo(uint index, out string name, out ItemPropId propID, out ushort varType)
 {
     this.EnterArchiveLock();
     try
     {
         this.Archive.GetPropertyInfo(index, out name, out propID, out varType);
     }
     finally
     {
         Monitor.Exit(this.ArchiveLock);
     }
 }
예제 #37
0
 internal Variant(IInArchive Archive, uint FileNumber, ItemPropId Id)
 {
     Archive.GetProperty(FileNumber, Id, ref variant);
 }
예제 #38
0
 public Variant GetProperty(UInt32 Index, ItemPropId propId)
 {
     return(new Variant(this, Index, propId));
 }
예제 #39
0
 public void GetArchiveProperty(ItemPropId propID, ref PropVariant value)
 {
     inArchive.GetArchiveProperty(propID, ref value);
 }
예제 #40
0
 void IArchiveOpenVolumeCallback.GetProperty(ItemPropId propID, ref PropVariant rv)
 {
     (owner as IArchiveOpenVolumeCallback).GetProperty(propID, ref rv);
 }
예제 #41
0
 public void GetProperty(UInt32 index, ItemPropId propID, ref PropVariant value)
 {
     inArchive.GetProperty(index, propID, ref value);
 }
예제 #42
0
        public int GetProperty(uint index, ItemPropId propID, ref PropVariant value)
        {
            index -= _indexOffset;
            try
            {
                switch (propID)
                {
                case ItemPropId.IsAnti:
                    value.VarType     = VarEnum.VT_BOOL;
                    value.UInt64Value = 0;
                    break;

                case ItemPropId.Path:
                    #region Path

                    value.VarType = VarEnum.VT_BSTR;
                    string val = DefaultItemName;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (_files == null)
                        {
                            if (_entries != null)
                            {
                                val = _entries[index];
                            }
                        }
                        else
                        {
                            if (_directoryStructure)
                            {
                                if (_rootLength > 0)
                                {
                                    val = _files[index].FullName.Substring(_rootLength);
                                }
                                else
                                {
                                    val = _files[index].FullName[0] + _files[index].FullName.Substring(2);
                                }
                            }
                            else
                            {
                                val = _files[index].Name;
                            }
                        }
                    }
                    else
                    {
                        val = _updateData.FileNamesToModify[(int)index];
                    }
                    value.Value = Marshal.StringToBSTR(val);
                    #endregion
                    break;

                case ItemPropId.IsDirectory:
                    value.VarType = VarEnum.VT_BOOL;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (_files == null)
                        {
                            if (_streams == null)
                            {
                                value.UInt64Value = 0;
                            }
                            else
                            {
                                value.UInt64Value = (ulong)(_streams[index] == null ? 1 : 0);
                            }
                        }
                        else
                        {
                            value.UInt64Value = (byte)(_files[index].Attributes & FileAttributes.Directory);
                        }
                    }
                    else
                    {
                        value.UInt64Value = Convert.ToUInt64(_updateData.ArchiveFileData[(int)index].IsDirectory);
                    }
                    break;

                case ItemPropId.Size:
                    #region Size

                    //zero 11-oct-2014 - this doesnt matter, we think it's only used for updating the progress indicator
                    value.VarType = VarEnum.VT_UI8;
                    //value.UInt64Value = unchecked((ulong)-1);
                    break;

                    value.VarType = VarEnum.VT_UI8;
                    UInt64 size;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (_files == null)
                        {
                            if (_streams == null)
                            {
                                size = _bytesCount > 0 ? (ulong)_bytesCount : 0;
                            }
                            else
                            {
                                size = (ulong)(_streams[index] == null? 0 : _streams[index].Length);
                            }
                        }
                        else
                        {
                            size = (_files[index].Attributes & FileAttributes.Directory) == 0
                                           ? (ulong)_files[index].Length
                                           : 0;
                        }
                    }
                    else
                    {
                        size = _updateData.ArchiveFileData[(int)index].Size;
                    }
                    value.UInt64Value = size;

                    #endregion
                    break;

                case ItemPropId.Attributes:
                    value.VarType = VarEnum.VT_UI4;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (_files == null)
                        {
                            if (_streams == null)
                            {
                                value.UInt32Value = (uint)FileAttributes.Normal;
                            }
                            else
                            {
                                value.UInt32Value = (uint)(_streams[index] == null ? FileAttributes.Directory : FileAttributes.Normal);
                            }
                        }
                        else
                        {
                            value.UInt32Value = (uint)_files[index].Attributes;
                        }
                    }
                    else
                    {
                        value.UInt32Value = _updateData.ArchiveFileData[(int)index].Attributes;
                    }
                    break;

                    #region Times
                case ItemPropId.CreationTime:
                    value.VarType = VarEnum.VT_FILETIME;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        value.Int64Value = _files == null
                                               ? DateTime.Now.ToFileTime()
                                               : _files[index].CreationTime.ToFileTime();
                    }
                    else
                    {
                        value.Int64Value = _updateData.ArchiveFileData[(int)index].CreationTime.ToFileTime();
                    }
                    break;

                case ItemPropId.LastAccessTime:
                    value.VarType = VarEnum.VT_FILETIME;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        value.Int64Value = _files == null
                                               ? DateTime.Now.ToFileTime()
                                               : _files[index].LastAccessTime.ToFileTime();
                    }
                    else
                    {
                        value.Int64Value = _updateData.ArchiveFileData[(int)index].LastAccessTime.ToFileTime();
                    }
                    break;

                case ItemPropId.LastWriteTime:
                    value.VarType = VarEnum.VT_FILETIME;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        value.Int64Value = _files == null
                                               ? DateTime.Now.ToFileTime()
                                               : _files[index].LastWriteTime.ToFileTime();
                    }
                    else
                    {
                        value.Int64Value = _updateData.ArchiveFileData[(int)index].LastWriteTime.ToFileTime();
                    }
                    break;

                    #endregion
                case ItemPropId.Extension:
                    #region Extension

                    value.VarType = VarEnum.VT_BSTR;
                    if (_updateData.Mode != InternalCompressionMode.Modify)
                    {
                        try
                        {
                            val = _files != null
                                      ? _files[index].Extension.Substring(1)
                                      : _entries == null
                                          ? ""
                                          : Path.GetExtension(_entries[index]);
                            value.Value = Marshal.StringToBSTR(val);
                        }
                        catch (ArgumentException)
                        {
                            value.Value = Marshal.StringToBSTR("");
                        }
                    }
                    else
                    {
                        val         = Path.GetExtension(_updateData.ArchiveFileData[(int)index].FileName);
                        value.Value = Marshal.StringToBSTR(val);
                    }

                    #endregion
                    break;
                }
            }
            catch (Exception e)
            {
                AddException(e);
            }
            return(0);
        }
예제 #43
0
 public void GetArchivePropertyInfo(UInt32 index, string name, out ItemPropId propID, out ushort varType)
 {
     inArchive.GetArchivePropertyInfo(index, name, out propID, out varType);
 }
예제 #44
0
            public int GetProperty(ItemPropId propID, ref PropVariant value)
            {
                switch (propID)
                {
                    case ItemPropId.kpidName:
                        value.VarType = VarEnum.VT_BSTR;
                        value.pointerValue = Marshal.StringToBSTR(archiveFile.FullName);
                        break;

                    case ItemPropId.kpidIsFolder:
                        value.VarType = VarEnum.VT_BOOL;
                        value.longValue = (byte)(archiveFile.Attributes & FileAttributes.Directory);
                        break;

                    case ItemPropId.kpidCreationTime:
                        value.VarType = VarEnum.VT_FILETIME;
                        value.longValue = archiveFile.CreationTime.ToFileTime();
                        break;

                    case ItemPropId.kpidLastAccessTime:
                        value.VarType = VarEnum.VT_FILETIME;
                        value.longValue = archiveFile.LastAccessTime.ToFileTime();
                        break;

                    case ItemPropId.kpidLastWriteTime:
                        value.VarType = VarEnum.VT_FILETIME;
                        value.longValue = archiveFile.LastWriteTime.ToFileTime();
                        break;

                    case ItemPropId.kpidSize:
                        value.VarType = VarEnum.VT_UI8;
                        value.longValue = archiveFile.Length;
                        break;
                }

                return 0;
            }
예제 #45
0
 public void GetProperty(ItemPropId propID, IntPtr value)
 {
     throw new System.NotImplementedException();
 }
예제 #46
0
 public void GetArchiveProperty(ItemPropId propID, ref PropVariant value)
 {
     inArchive.GetArchiveProperty(propID, ref value);
 }
        private string Write160_ItemPropId(ItemPropId v)
        {
            long num;
            ItemPropId id = v;
            if (id <= ItemPropId.kpidVolumeName)
            {
                switch (id)
                {
                    case ItemPropId.kpidNoProperty:
                        return "kpidNoProperty";

                    case ((ItemPropId) 1):
                        goto Label_03AE;

                    case ItemPropId.kpidHandlerItemIndex:
                        return "kpidHandlerItemIndex";

                    case ItemPropId.kpidPath:
                        return "kpidPath";

                    case ItemPropId.kpidName:
                        return "kpidName";

                    case ItemPropId.kpidExtension:
                        return "kpidExtension";

                    case ItemPropId.kpidIsFolder:
                        return "kpidIsFolder";

                    case ItemPropId.kpidSize:
                        return "kpidSize";

                    case ItemPropId.kpidPackedSize:
                        return "kpidPackedSize";

                    case ItemPropId.kpidAttributes:
                        return "kpidAttributes";

                    case ItemPropId.kpidCreationTime:
                        return "kpidCreationTime";

                    case ItemPropId.kpidLastAccessTime:
                        return "kpidLastAccessTime";

                    case ItemPropId.kpidLastWriteTime:
                        return "kpidLastWriteTime";

                    case ItemPropId.kpidSolid:
                        return "kpidSolid";

                    case ItemPropId.kpidCommented:
                        return "kpidCommented";

                    case ItemPropId.kpidEncrypted:
                        return "kpidEncrypted";

                    case ItemPropId.kpidSplitBefore:
                        return "kpidSplitBefore";

                    case ItemPropId.kpidSplitAfter:
                        return "kpidSplitAfter";

                    case ItemPropId.kpidDictionarySize:
                        return "kpidDictionarySize";

                    case ItemPropId.kpidCRC:
                        return "kpidCRC";

                    case ItemPropId.kpidType:
                        return "kpidType";

                    case ItemPropId.kpidIsAnti:
                        return "kpidIsAnti";

                    case ItemPropId.kpidMethod:
                        return "kpidMethod";

                    case ItemPropId.kpidHostOS:
                        return "kpidHostOS";

                    case ItemPropId.kpidFileSystem:
                        return "kpidFileSystem";

                    case ItemPropId.kpidUser:
                        return "kpidUser";

                    case ItemPropId.kpidGroup:
                        return "kpidGroup";

                    case ItemPropId.kpidBlock:
                        return "kpidBlock";

                    case ItemPropId.kpidComment:
                        return "kpidComment";

                    case ItemPropId.kpidPosition:
                        return "kpidPosition";

                    case ItemPropId.kpidPrefix:
                        return "kpidPrefix";

                    case ItemPropId.kpidNumSubFolders:
                        return "kpidNumSubFolders";

                    case ItemPropId.kpidNumSubFiles:
                        return "kpidNumSubFiles";

                    case ItemPropId.kpidUnpackVer:
                        return "kpidUnpackVer";

                    case ItemPropId.kpidVolume:
                        return "kpidVolume";

                    case ItemPropId.kpidIsVolume:
                        return "kpidIsVolume";

                    case ItemPropId.kpidOffset:
                        return "kpidOffset";

                    case ItemPropId.kpidLinks:
                        return "kpidLinks";

                    case ItemPropId.kpidNumBlocks:
                        return "kpidNumBlocks";

                    case ItemPropId.kpidNumVolumes:
                        return "kpidNumVolumes";

                    case ItemPropId.kpidTimeType:
                        return "kpidTimeType";

                    case ItemPropId.kpidBit64:
                        return "kpidBit64";

                    case ItemPropId.kpidBigEndian:
                        return "kpidBigEndian";

                    case ItemPropId.kpidCpu:
                        return "kpidCpu";

                    case ItemPropId.kpidPhySize:
                        return "kpidPhySize";

                    case ItemPropId.kpidHeadersSize:
                        return "kpidHeadersSize";

                    case ItemPropId.kpidChecksum:
                        return "kpidChecksum";

                    case ItemPropId.kpidCharacts:
                        return "kpidCharacts";

                    case ItemPropId.kpidVa:
                        return "kpidVa";

                    case ItemPropId.kpidId:
                        return "kpidId";

                    case ItemPropId.kpidShortName:
                        return "kpidShortName";

                    case ItemPropId.kpidCreatorApp:
                        return "kpidCreatorApp";

                    case ItemPropId.kpidSectorSize:
                        return "kpidSectorSize";

                    case ItemPropId.kpidPosixAttrib:
                        return "kpidPosixAttrib";

                    case ItemPropId.kpidLink:
                        return "kpidLink";

                    case ItemPropId.kpidTotalSize:
                        return "kpidTotalSize";

                    case ItemPropId.kpidFreeSpace:
                        return "kpidFreeSpace";

                    case ItemPropId.kpidClusterSize:
                        return "kpidClusterSize";

                    case ItemPropId.kpidVolumeName:
                        return "kpidVolumeName";
                }
            }
            else
            {
                switch (id)
                {
                    case ItemPropId.kpidLocalName:
                        return "kpidLocalName";

                    case ItemPropId.kpidProvider:
                        return "kpidProvider";

                    case ItemPropId.kpidUserDefined:
                        return "kpidUserDefined";
                }
            }
        Label_03AE:
            num = (long) ((ulong) v);
            throw base.CreateInvalidEnumValueException(num.ToString(CultureInfo.InvariantCulture), "Nomad.FileSystem.Archive.SevenZip.ItemPropId");
        }
        public int GetProperty(uint index, ItemPropId propID, ref PropVariant value)
        {
            index -= this._IndexOffset;
            try
            {
                switch (propID)
                {
                case ItemPropId.Path:
                    value.VarType = VarEnum.VT_BSTR;
                    string s1 = "default";
                    if (this._UpdateData.Mode != InternalCompressionMode.Modify)
                    {
                        if (this._Files == null)
                        {
                            if (this._Entries != null)
                            {
                                s1 = this._Entries[index];
                            }
                        }
                        else
                        {
                            s1 = !this._DirectoryStructure ? this._Files[index].Name : (this._RootLength <= 0 ? ((int)this._Files[index].FullName[0]).ToString() + this._Files[index].FullName.Substring(2) : this._Files[index].FullName.Substring(this._RootLength));
                        }
                    }
                    else
                    {
                        s1 = this._UpdateData.FileNamesToModify[(int)index];
                    }
                    value.Value = Marshal.StringToBSTR(s1);
                    break;

                case ItemPropId.Extension:
                    value.VarType = VarEnum.VT_BSTR;
                    if (this._UpdateData.Mode != InternalCompressionMode.Modify)
                    {
                        try
                        {
                            string s2 = this._Files != null ? this._Files[index].Extension.Substring(1) : (this._Entries == null ? "" : Path.GetExtension(this._Entries[index]));
                            value.Value = Marshal.StringToBSTR(s2);
                            break;
                        }
                        catch (ArgumentException ex)
                        {
                            value.Value = Marshal.StringToBSTR("");
                            break;
                        }
                    }
                    else
                    {
                        string extension = Path.GetExtension(this._UpdateData.ArchiveFileData[(int)index].FileName);
                        value.Value = Marshal.StringToBSTR(extension);
                        break;
                    }

                case ItemPropId.IsDirectory:
                    value.VarType     = VarEnum.VT_BOOL;
                    value.UInt64Value = this._UpdateData.Mode == InternalCompressionMode.Modify ? Convert.ToUInt64(this._UpdateData.ArchiveFileData[(int)index].IsDirectory) : (this._Files == null ? 0UL : (ulong)(byte)(this._Files[index].Attributes & FileAttributes.Directory));
                    break;

                case ItemPropId.Size:
                    value.VarType = VarEnum.VT_UI8;
                    ulong num = this._UpdateData.Mode == InternalCompressionMode.Modify ? this._UpdateData.ArchiveFileData[(int)index].Size : (this._Files != null ? ((this._Files[index].Attributes & FileAttributes.Directory) == (FileAttributes)0 ? (ulong)this._Files[index].Length : 0UL) : (this._Streams != null ? (ulong)this._Streams[index].Length : (this._BytesCount > 0L ? (ulong)this._BytesCount : 0UL)));
                    value.UInt64Value = num;
                    break;

                case ItemPropId.Attributes:
                    value.VarType     = VarEnum.VT_UI4;
                    value.UInt32Value = this._UpdateData.Mode == InternalCompressionMode.Modify ? this._UpdateData.ArchiveFileData[(int)index].Attributes : (this._Files == null ? 32U : (uint)this._Files[index].Attributes);
                    break;

                case ItemPropId.CreationTime:
                    value.VarType    = VarEnum.VT_FILETIME;
                    value.Int64Value = this._UpdateData.Mode == InternalCompressionMode.Modify ? this._UpdateData.ArchiveFileData[(int)index].CreationTime.ToFileTime() : (this._Files == null ? DateTime.Now.ToFileTime() : this._Files[index].CreationTime.ToFileTime());
                    break;

                case ItemPropId.LastAccessTime:
                    value.VarType    = VarEnum.VT_FILETIME;
                    value.Int64Value = this._UpdateData.Mode == InternalCompressionMode.Modify ? this._UpdateData.ArchiveFileData[(int)index].LastAccessTime.ToFileTime() : (this._Files == null ? DateTime.Now.ToFileTime() : this._Files[index].LastAccessTime.ToFileTime());
                    break;

                case ItemPropId.LastWriteTime:
                    value.VarType    = VarEnum.VT_FILETIME;
                    value.Int64Value = this._UpdateData.Mode == InternalCompressionMode.Modify ? this._UpdateData.ArchiveFileData[(int)index].LastWriteTime.ToFileTime() : (this._Files == null ? DateTime.Now.ToFileTime() : this._Files[index].LastWriteTime.ToFileTime());
                    break;

                case ItemPropId.IsAnti:
                    value.VarType     = VarEnum.VT_BOOL;
                    value.UInt64Value = 0UL;
                    break;
                }
            }
            catch (Exception ex)
            {
                this.AddException(ex);
            }
            return(0);
        }
예제 #49
0
            public void GetProperty(int index, ItemPropId propID, ref PropVariant value)
            {
                switch (propID)
                {
                    case ItemPropId.kpidPath:
                        value.VarType = VarEnum.VT_BSTR;
                        value.pointerValue = Marshal.StringToBSTR(Path.GetFileName(filename));
                        break;

                    case ItemPropId.kpidIsFolder:
                    case ItemPropId.kpidIsAnti:
                        value.VarType = VarEnum.VT_BOOL;
                        value.longValue = 0;
                        break;

                    case ItemPropId.kpidCreationTime:
                        value.VarType = VarEnum.VT_FILETIME;
                        value.longValue = (documentEntry.FileDate ?? DateTime.Now).ToFileTime();
                        break;

                    case ItemPropId.kpidLastAccessTime:
                        value.VarType = VarEnum.VT_FILETIME;
                        value.longValue = (documentEntry.FileDate ?? DateTime.Now).ToFileTime();
                        break;

                    case ItemPropId.kpidLastWriteTime:
                        value.VarType = VarEnum.VT_FILETIME;
                        value.longValue = (documentEntry.FileDate ?? DateTime.Now).ToFileTime();
                        break;

                    case ItemPropId.kpidSize:
                        value.VarType = VarEnum.VT_UI8;
                        value.longValue = content.Length;
                        break;
                }
            }
예제 #50
0
 public void GetProperty(ItemPropId propID, IntPtr value)
 {
     throw new System.NotImplementedException();
 }
예제 #51
0
        public int GetProperty(uint index, ItemPropId propID, ref PropVariant value)
        {
            index -= _indexOffset;
            try
            {
                switch (propID)
                {
                    case ItemPropId.IsAnti:
                        value.VarType = VarEnum.VT_BOOL;
                        value.UInt64Value = 0;
                        break;
                    case ItemPropId.Path:
                        #region Path

                        value.VarType = VarEnum.VT_BSTR;
                        string val = DefaultItemName;
                        if (_updateData.Mode != InternalCompressionMode.Modify)
                        {
                            if (_files == null)
                            {
                                if (_entries != null)
                                {
                                    val = _entries[index];
                                }
                            }
                            else
                            {
                                if (_directoryStructure)
                                {
                                    if (_rootLength > 0)
                                    {
                                        val = _files[index].FullName.Substring(_rootLength);
                                    }
                                    else
                                    {
                                        val = _files[index].FullName[0] + _files[index].FullName.Substring(2);
                                    }
                                }
                                else
                                {
                                    val = _files[index].Name;
                                }
                            }
                        }
                        else
                        {
                            val = _updateData.FileNamesToModify[(int) index];
                        }
                        value.Value = Marshal.StringToBSTR(val);
                        #endregion
                        break;
                    case ItemPropId.IsDirectory:
                        value.VarType = VarEnum.VT_BOOL;
                        if (_updateData.Mode != InternalCompressionMode.Modify)
                        {
                            if (_files == null)
                            {
                                if (_streams == null)
                                {
                                    value.UInt64Value = 0;
                                }
                                else
                                {
                                    value.UInt64Value = (ulong)(_streams[index] == null ? 1 : 0);
                                }
                            }
                            else
                            {
                                value.UInt64Value = (byte)(_files[index].Attributes & FileAttributes.Directory);
                            }
                        }
                        else
                        {
                            value.UInt64Value = Convert.ToUInt64(_updateData.ArchiveFileData[(int) index].IsDirectory);
                        }
                        break;
                    case ItemPropId.Size:
                        #region Size

                        value.VarType = VarEnum.VT_UI8;
                        UInt64 size;
                        if (_updateData.Mode != InternalCompressionMode.Modify)
                        {
                            if (_files == null)
                            {
                                if (_streams == null)
                                {
                                    size = _bytesCount > 0 ? (ulong) _bytesCount : 0;
                                }
                                else
                                {
                                    size = (ulong) (_streams[index] == null? 0 : _streams[index].Length);
                                }
                            }
                            else
                            {
                                size = (_files[index].Attributes & FileAttributes.Directory) == 0
                                           ? (ulong) _files[index].Length
                                           : 0;
                            }
                        }
                        else
                        {
                            size = _updateData.ArchiveFileData[(int) index].Size;
                        }
                        value.UInt64Value = size;

                        #endregion
                        break;
                    case ItemPropId.Attributes:
                        value.VarType = VarEnum.VT_UI4;
                        if (_updateData.Mode != InternalCompressionMode.Modify)
                        {
                            if (_files == null)
                            {
                                if (_streams == null)
                                {
                                    value.UInt32Value = (uint)FileAttributes.Normal;
                                }
                                else
                                {
                                    value.UInt32Value = (uint)(_streams[index] == null ? FileAttributes.Directory : FileAttributes.Normal);
                                }
                            }
                            else
                            {
                                value.UInt32Value = (uint) _files[index].Attributes;
                            }
                        }
                        else
                        {
                            value.UInt32Value = _updateData.ArchiveFileData[(int) index].Attributes;
                        }
                        break;
                    #region Times
                    case ItemPropId.CreationTime:
                        value.VarType = VarEnum.VT_FILETIME;
                        if (_updateData.Mode != InternalCompressionMode.Modify)
                        {
                            value.Int64Value = _files == null
                                               ? DateTime.Now.ToFileTime()
                                               : _files[index].CreationTime.ToFileTime();
                        }
                        else
                        {
                            value.Int64Value = _updateData.ArchiveFileData[(int) index].CreationTime.ToFileTime();
                        }
                        break;
                    case ItemPropId.LastAccessTime:
                        value.VarType = VarEnum.VT_FILETIME;
                        if (_updateData.Mode != InternalCompressionMode.Modify)
                        {
                            value.Int64Value = _files == null
                                               ? DateTime.Now.ToFileTime()
                                               : _files[index].LastAccessTime.ToFileTime();
                        }
                        else
                        {
                            value.Int64Value = _updateData.ArchiveFileData[(int) index].LastAccessTime.ToFileTime();
                        }
                        break;
                    case ItemPropId.LastWriteTime:
                        value.VarType = VarEnum.VT_FILETIME;
                        if (_updateData.Mode != InternalCompressionMode.Modify)
                        {
                            value.Int64Value = _files == null
                                               ? DateTime.Now.ToFileTime()
                                               : _files[index].LastWriteTime.ToFileTime();
                        }
                        else
                        {
                            value.Int64Value = _updateData.ArchiveFileData[(int) index].LastWriteTime.ToFileTime();
                        }
                        break;
                    #endregion
                    case ItemPropId.Extension:
                        #region Extension

                        value.VarType = VarEnum.VT_BSTR;
                        if (_updateData.Mode != InternalCompressionMode.Modify)
                        {
                            try
                            {
                                val = _files != null
                                      ? _files[index].Extension.Substring(1)
                                      : _entries == null
                                          ? ""
                                          : Path.GetExtension(_entries[index]);
                                value.Value = Marshal.StringToBSTR(val);
                            }
                            catch (ArgumentException)
                            {
                                value.Value = Marshal.StringToBSTR("");
                            }
                        }
                        else
                        {
                            val = Path.GetExtension(_updateData.ArchiveFileData[(int) index].FileName);
                            value.Value = Marshal.StringToBSTR(val);
                        }

                        #endregion
                        break;
                }
            }
            catch (Exception e)
            {
                AddException(e);
            }
            return 0;
        }
 public void GetProperty(uint index, ItemPropId propID, ref PropVariant value)
 {
     this.EnterArchiveLock();
     try
     {
         this.Archive.GetProperty(index, propID, ref value);
     }
     finally
     {
         Monitor.Exit(this.ArchiveLock);
     }
 }