Ejemplo n.º 1
0
        private void ReadFrom(BinaryReader bR)
        {
            switch (bR.ReadByte())
            {
            case 0:     //eof reached
                break;

            case 1:
                _name            = Encoding.UTF8.GetString(bR.ReadBytes(bR.ReadByte()));
                _lastModifiedUTC = DateTime.FromBinary(bR.ReadInt64());
                _attributes      = (PackageItemAttributes)bR.ReadByte();

                _extractTo = (ExtractLocation)bR.ReadByte();
                if (_extractTo == ExtractLocation.Custom)
                {
                    _extractToCustomLocation = Encoding.UTF8.GetString(bR.ReadBytes(bR.ReadByte()));
                }

                long length = bR.ReadInt64();
                _data = new OffsetStream(bR.BaseStream, bR.BaseStream.Position, length, true);

                bR.BaseStream.Position += length;

                break;

            default:
                throw new IOException("PackageItem version not supported.");
            }
        }
Ejemplo n.º 2
0
        public PackageItem(string name, Stream s)
        {
            _name            = name;
            _lastModifiedUTC = DateTime.UtcNow;
            _attributes      = PackageItemAttributes.None;

            _extractTo = ExtractLocation.None;
            _extractToCustomLocation = null;

            _data = s;
        }
Ejemplo n.º 3
0
        public PackageItem(string name, DateTime lastModifiedUTC, Stream s, PackageItemAttributes attributes = PackageItemAttributes.None, ExtractLocation extractTo = ExtractLocation.None, string extractToCustomLocation = null)
        {
            _name            = name;
            _lastModifiedUTC = lastModifiedUTC;
            _attributes      = attributes;

            _extractTo = extractTo;

            if (extractTo == ExtractLocation.Custom)
            {
                _extractToCustomLocation = extractToCustomLocation;
            }

            _data = s;
        }
Ejemplo n.º 4
0
        public PackageItem(string filepath, PackageItemAttributes attributes = PackageItemAttributes.None, ExtractLocation extractTo = ExtractLocation.None, string extractToCustomLocation = null)
        {
            _name            = Path.GetFileName(filepath);
            _lastModifiedUTC = File.GetLastWriteTimeUtc(filepath);
            _attributes      = attributes;

            _extractTo = extractTo;

            if (extractTo == ExtractLocation.Custom)
            {
                _extractToCustomLocation = extractToCustomLocation;
            }

            _data      = new FileStream(filepath, FileMode.Open, FileAccess.Read);
            _ownStream = true;
        }
Ejemplo n.º 5
0
 public bool IsAttributeSet(PackageItemAttributes attribute)
 {
     return((_attributes & attribute) > 0);
 }