Esempio 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.");
            }
        }
Esempio n. 2
0
        public PackageItem(string name, Stream s)
        {
            _name            = name;
            _lastModifiedUTC = DateTime.UtcNow;
            _attributes      = PackageItemAttributes.None;

            _extractTo = ExtractLocation.None;
            _extractToCustomLocation = null;

            _data = s;
        }
Esempio 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;
        }
Esempio 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;
        }
Esempio n. 5
0
 public bool IsAttributeSet(PackageItemAttributes attribute)
 {
     return((_attributes & attribute) > 0);
 }