/// <summary>
        /// Get an archive of a given repository's contents, using a specific format and reference
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        public IObservable <byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(reference, "reference");

            return(GetArchive(owner, name, archiveFormat, reference, TimeSpan.FromMinutes(60)));
        }
        /// <summary>
        /// Get an archive of a given repository's contents, in a specific format
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        /// <param name="timeout"> Time span until timeout </param>
        /// <returns>The binary contents of the archive</returns>
        public IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.GreaterThanZero(timeout, "timeout");

            return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference, timeout).ToObservable();
        }
Beispiel #3
0
 public CommitLog(DateTime date, string message, Func <DateTime, string, string> filenameFormatter, ArchiveFormat format, string savedPath)
 {
     Date      = date;
     Message   = message;
     Filename  = filenameFormatter(date, message);
     Format    = format;
     SavedPath = savedPath;
 }
Beispiel #4
0
 public CommitLog(DateTime date, string message, string filename, ArchiveFormat format, string savedPath)
 {
     Date      = date;
     Message   = message;
     Filename  = filename;
     Format    = format;
     SavedPath = savedPath;
 }
Beispiel #5
0
 public GanFrameArchive(ArcView arc, ArchiveFormat impl, ICollection <Entry> dir)
     : base(arc, impl, dir)
 {
     Info = new ImageMetaData {
         Width = DefaultWidth, Height = DefaultHeight, BPP = 24
     };
     Frames = new byte[dir.Count][];
 }
Beispiel #6
0
 public NpaArchive(ArcView arc, ArchiveFormat impl, ICollection <Entry> dir,
                   EncryptionScheme scheme, int key)
     : base(arc, impl, dir)
 {
     Scheme      = scheme;
     Key         = key;
     m_key_table = new Lazy <byte[]> (() => NpaOpener.GenerateKeyTable(scheme));
 }
Beispiel #7
0
        public Task <byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
            Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
            Ensure.ArgumentNotNull(reference, nameof(reference));

            return(GetArchive(owner, name, archiveFormat, reference, TimeSpan.FromMinutes(60)));
        }
Beispiel #8
0
 internal PscxSevenZipExtractor(PscxCmdlet command, FileInfo file, bool passThru, ArchiveFormat format) :
     base(command, file, format)
 {
     _passThru = passThru;
     _entries = new List<ArchiveEntry>();
     foreach (ArchiveEntry entry in this){
         _entries.Add(entry);
     }
 }
Beispiel #9
0
 public List <Entry> Read()
 {
     byte[] packed;
     using (var input = m_file.CreateStream(12, m_data_offset - 12))
         using (var bits = new MsbBitStream(input))
         {
             bits.GetNextBit();
             m_dict = ReadBytes(bits);
             if (null == m_dict)
             {
                 return(null);
             }
             int packed_size   = ReadInt32(bits);
             int unpacked_size = ReadInt32(bits);
             packed = new byte[packed_size];
             for (int i = 0; i < packed_size; ++i)
             {
                 packed[i] = (byte)bits.GetBits(8);
             }
         }
     using (var bstr = new BinMemoryStream(packed))
         using (var zstr = new ZLibStream(bstr, CompressionMode.Decompress))
             using (var index = new MsbBitStream(zstr))
             {
                 index.GetNextBit();
                 int count = ReadInt32(index);
                 if (!ArchiveFormat.IsSaneCount(count))
                 {
                     return(null);
                 }
                 var dir = new List <Entry> (count);
                 for (int i = 0; i < count; ++i)
                 {
                     if (index.GetBits(2) == -1)
                     {
                         break;
                     }
                     var name_buf = ReadEncryptedChars(index);
                     if (null == name_buf)
                     {
                         return(null);
                     }
                     var name  = DecryptString(name_buf, name_buf.Length);
                     var entry = FormatCatalog.Instance.Create <Entry> (name);
                     ReadInt32(index);
                     ReadInt32(index);
                     entry.Offset = (uint)ReadInt32(index) + m_data_offset;
                     entry.Size   = (uint)ReadInt32(index);
                     if (!entry.CheckPlacement(m_file.MaxOffset))
                     {
                         return(null);
                     }
                     dir.Add(entry);
                 }
                 return(dir);
             }
 }
Beispiel #10
0
        protected SevenZipBaseEx(PscxCmdlet command, FileInfo file, ArchiveFormat format)
        {
            //Debug.Assert(format != ArchiveFormat.Unknown, "format != ArchiveFormat.Unknown");

            _command         = command;
            _file            = file;
            _format          = format;
            _archivePscxPath = PscxPathInfo.GetPscxPathInfo(_command.SessionState, file.FullName);
        }
Beispiel #11
0
        internal static Guid GetClassIdFromKnownFormat(ArchiveFormat format)
        {
            Guid result;

            if (FormatClassMap.TryGetValue(format, out result))
            {
                return(result);
            }
            return(Guid.Empty);
        }
Beispiel #12
0
        // Archive object for creation
        public Archive(ArchiveFormat format, string filename)
        {
            // Set up information
            Name      = null;
            Extension = null;
            Filename  = filename;
            Format    = format;

            InitalizePacker();
        }
Beispiel #13
0
        public SafIndexReader6(ArchiveFormat saf, byte[] index, byte[] names, int count) : base(saf, index, count)
        {
            m_names = names;

            EntrySize   = 16;
            OffsetPos   = 4;
            SizePos     = 8;
            UnpackedPos = 12;
            DirIndexPos = 4;
            DirCountPos = 12;
        }
Beispiel #14
0
 public LayArchive(ArcView arc, ArchiveFormat impl, ICollection <Entry> dir, BitmapSource image, IList <LayCoord> tiles)
     : base(arc, impl, dir)
 {
     Source   = image;
     Tiles    = tiles;
     LayerMap = new Dictionary <uint, LayEntry> (dir.Count);
     foreach (LayEntry entry in dir)
     {
         LayerMap[entry.Id] = entry;
     }
 }
Beispiel #15
0
        public BdfArchive(ArcView arc, ArchiveFormat impl, ICollection <Entry> dir)
            : base(arc, impl, dir)
        {
            var base_frame = dir.First() as BdfFrame;

            Info = new ImageMetaData {
                Width  = (uint)base_frame.Width,
                Height = (uint)base_frame.Height,
                BPP    = 24
            };
        }
        public override void ExportArchive(PrivateKey pk, IEnumerable <Crt> certs, ArchiveFormat fmt, Stream target, string password)
        {
            var rsaPk = pk as RsaPrivateKey;

            if (rsaPk == null)
            {
                throw new NotSupportedException("unsupported private key type");
            }

            if (fmt == ArchiveFormat.PKCS12)
            {
                var bcCerts = certs.Select(x =>
                                           new X509CertificateEntry(FromCertPem(x.Pem))).ToArray();
                var bcPk = FromPrivatePem(rsaPk.Pem);

                var pfx = new Pkcs12Store();
                //pfx.SetCertificateEntry(bcCerts[0].Certificate.ToString(), bcCerts[0]);
                //pfx.SetKeyEntry(bcCerts[0].Certificate.ToString(),
                pfx.SetCertificateEntry(string.Empty, bcCerts[0]);
                pfx.SetKeyEntry(string.Empty,
                                new AsymmetricKeyEntry(bcPk.Private), new[] { bcCerts[0] });

                for (int i = 1; i < bcCerts.Length; ++i)
                {
                    //pfx.SetCertificateEntry(bcCerts[i].Certificate.SubjectDN.ToString(),
                    pfx.SetCertificateEntry(i.ToString(), bcCerts[i]);
                }

                // It used to be pretty straight forward to export this...
                //pfx.Save(target, password?.ToCharArray(), new SecureRandom());

                // ...unfortunately, BC won't let us export the Pkcs12 archive
                // without assigning a FriendlyName, so we have to export and
                // then re-import it, clear the FriendlyName, then return that
                // YUCK!
                using (var tmp = new MemoryStream())
                {
                    pfx.Save(tmp, null, new SecureRandom());
                    var c = new System.Security.Cryptography.X509Certificates.X509Certificate2();
                    c.Import(tmp.ToArray(), string.Empty,
                             System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.PersistKeySet |
                             System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable);

                    // Clear the FriendlyName
                    c.FriendlyName = null;
                    var bytes = c.Export(System.Security.Cryptography.X509Certificates.X509ContentType.Pkcs12, password);
                    target.Write(bytes, 0, bytes.Length);
                }
            }
            else
            {
                throw new NotSupportedException("unsupported archive format");
            }
        }
Beispiel #17
0
        /// <summary>
        /// Get an archive of a given repository's contents, using a specific format and reference
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        /// <returns>The binary contents of the archive</returns>
        public async Task <byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference);

            var response = await Connection.Get <byte[]>(endpoint, TimeSpan.FromMinutes(60));

            return(response.Body);
        }
 public ProgramPackage(
     Stream stream,
     ArchiveFormat format,
     byte[] sha256,
     Uid?dekId = null)
 {
     Stream = stream ?? throw new ArgumentNullException(nameof(stream));
     Format = format;
     Sha256 = sha256 ?? throw new ArgumentNullException(nameof(sha256));
     DekId  = dekId;
 }
        /// <summary>
        /// Get an archive of a given repository's contents, in a specific format
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        /// <param name="timeout"> Time span until timeout </param>
        public async Task <byte[]> GetArchive(int repositoryId, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
        {
            Ensure.ArgumentNotNull(reference, "reference");
            Ensure.GreaterThanZero(timeout, "timeout");

            var endpoint = ApiUrls.RepositoryArchiveLink(repositoryId, archiveFormat, reference);

            var response = await Connection.Get <byte[]>(endpoint, timeout).ConfigureAwait(false);

            return(response.Body);
        }
Beispiel #20
0
        /// <summary>
        /// Get an archive of a given repository's contents, in a specific format
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        /// <param name="timeout"> Time span until timeout </param>
        /// <returns>The binary contents of the archive</returns>
        public async Task <byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.GreaterThanZero(timeout, "timeout");

            var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference);

            var response = await Connection.Get <byte[]>(endpoint, timeout);

            return(response.Body);
        }
Beispiel #21
0
        /// <summary>
        /// Towrzenie nowego zestawu kompresji
        /// </summary>
        /// <param name="name">Nazwa zestwu</param>
        /// <param name="compression">Prędkość kompresji</param>
        /// <param name="format">Format archiwum</param>
        /// <param name="method">Metoda kompresji</param>
        /// <param name="directory">Lokalizacja plików do kompresji</param>
        /// <param name="outputDirectory">Lokalizacja zapisu archiwum</param>
        /// <param name="filesToTake">Lista plików do kompresji.</param>
        public CompressionData(string name, Compression compression, ArchiveFormat format, Method method, string directory, string outputDirectory, params string[] filesToTake)
        {
            Directory       = directory;
            Name            = name;
            Method          = method;
            ArchiveFormat   = format;
            OutputDirectory = outputDirectory;
            Compression     = compression;

            FormatsToTake = null;
            FilesToTake   = filesToTake;
        }
Beispiel #22
0
        /// <summary>
        /// Towrzenie nowego zestawu kompresji
        /// </summary>
        /// <param name="name">Nazwa zestwu</param>
        /// <param name="compression">Prędkość kompresji</param>
        /// <param name="format">Format archiwum</param>
        /// <param name="method">Metoda kompresji</param>
        /// <param name="directory">Lokalizacja plików do kompresji</param>
        /// <param name="outputDirectory">Lokalizacja zapisu archiwum</param>
        /// <param name="formatsToTake">Format plików do kompresji. Domyślnie Format.All (Wszystkie)</param>
        public CompressionData(string name, Compression compression, ArchiveFormat format, Method method, string directory, string outputDirectory, Format[] formatsToTake = null)
        {
            Directory       = directory;
            Name            = name;
            Method          = method;
            ArchiveFormat   = format;
            OutputDirectory = outputDirectory;
            Compression     = compression;

            FilesToTake   = null;
            FormatsToTake = (formatsToTake == null || formatsToTake.Contains(Format.All) || formatsToTake.Length == 0) ? new[] { Format.All } : formatsToTake;
        }
        /// <summary>
        /// Creates a deep copy of 'mod'.
        /// </summary>
        /// <param name="mod">The object it makes a copy of.</param>
        public ManagedMod(ManagedMod mod)
        {
            /*
             * Info
             */

            this.title             = mod.title;
            this.ID                = mod.ID;
            this.URL               = mod.URL;
            this.Version           = mod.Version;
            this.guid              = mod.guid;
            this.GamePath          = mod.GamePath;
            this.ManagedFolderName = mod.ManagedFolderName;


            /*
             * General
             */
            this.Enabled        = mod.Enabled;
            this.Deployed       = mod.Deployed;
            this.Method         = mod.Method;
            this.PreviousMethod = mod.PreviousMethod;


            /*
             * SeparateBA2
             */

            this.archiveName        = mod.archiveName;
            this.CurrentArchiveName = mod.CurrentArchiveName;
            this.Compression        = mod.Compression;
            this.CurrentCompression = mod.CurrentCompression;
            this.Format             = mod.Format;
            this.CurrentFormat      = mod.CurrentFormat;


            /*
             * SeparateBA2 Frozen
             */
            this.Freeze            = mod.Freeze;
            this.Frozen            = mod.Frozen;
            this.FrozenCompression = mod.FrozenCompression;
            this.FrozenFormat      = mod.FrozenFormat;


            /*
             * Loose
             */
            this.LooseFiles        = new List <string>(mod.LooseFiles);
            this.RootFolder        = mod.RootFolder;
            this.CurrentRootFolder = mod.CurrentRootFolder;
        }
Beispiel #24
0
        public List <Entry> ReadIndex(uint entry_size)
        {
            int count = (int)(m_index.MaxOffset / entry_size);

            if (!ArchiveFormat.IsSaneCount(count))
            {
                return(null);
            }
            if (null == m_dir)
            {
                m_dir = new List <Entry> (count);
            }
            else
            {
                m_dir.Clear();
            }
            uint idx_offset = 0;

            for (int i = 0; i < count; ++i)
            {
                if (idx_offset + entry_size > m_index.MaxOffset)
                {
                    return(null);
                }
                int name_offset = m_index.View.ReadInt32(idx_offset);
                if (name_offset < 0 || name_offset >= m_names.Length)
                {
                    return(null);
                }
                var name  = Binary.GetCString(m_names, name_offset, m_names.Length - name_offset);
                var entry = FormatCatalog.Instance.Create <PackedEntry> (name);
                entry.Offset = m_index.View.ReadUInt32(idx_offset + 4);
                entry.Size   = m_index.View.ReadUInt32(idx_offset + 8);
                if (!entry.CheckPlacement(m_arc.MaxOffset))
                {
                    return(null);
                }
                entry.IsPacked = true;
                if (entry_size >= 0x14)
                {
                    entry.UnpackedSize = m_index.View.ReadUInt32(idx_offset + 0x10);
                }
                if (name.EndsWith(".bmp.txt", StringComparison.OrdinalIgnoreCase))
                {
                    entry.Type = "image";
                }
                m_dir.Add(entry);
                idx_offset += entry_size;
            }
            return(m_dir);
        }
        public static string ToTypeString(this ArchiveFormat ot)
        {
            switch (ot)
            {
            case ArchiveFormat.ArchiveZip:
                return("zip");

            case ArchiveFormat.ArchiveTarGz:
                return("tar.gz");

            default:
                return("");
            }
        }
Beispiel #26
0
        public List <Entry> ReadIndexV2()
        {
            if (!ArchiveFormat.IsSaneCount((int)m_count))
            {
                return(null);
            }

            uint names_size = m_file.View.ReadUInt32(0x10) ^ NextKey();
            uint index_size = m_count * 12;
            var  index      = m_file.View.ReadBytes(0x14, index_size);

            if (index.Length != index_size)
            {
                return(null);
            }
            uint filenames_base = 0x14 + index_size;
            var  names          = m_file.View.ReadBytes(filenames_base, names_size);

            if (names.Length != names_size)
            {
                return(null);
            }
            Decrypt(index);
            int index_offset = 0;
            var dir          = new List <Entry> ((int)m_count);

            for (uint i = 0; i < m_count; ++i)
            {
                int filename_offset = LittleEndian.ToInt32(index, index_offset);
                if (filename_offset < 0 || filename_offset >= names.Length)
                {
                    return(null);
                }
                var name = Binary.GetCString(names, filename_offset, names.Length - filename_offset);
                if (0 == name.Length)
                {
                    return(null);
                }
                var entry = FormatCatalog.Instance.Create <Entry> (name);
                entry.Offset = LittleEndian.ToUInt32(index, index_offset + 4);
                entry.Size   = LittleEndian.ToUInt32(index, index_offset + 8);
                if (!entry.CheckPlacement(m_file.MaxOffset))
                {
                    return(null);
                }
                index_offset += 12;
                dir.Add(entry);
            }
            return(dir);
        }
Beispiel #27
0
        public override void ExportArchive(PrivateKey pk, IEnumerable <Crt> certs, ArchiveFormat fmt, Stream target, string password = "")
        {
            var rsaPk = pk as RsaPrivateKey;

            if (rsaPk == null)
            {
                throw new NotSupportedException("unsupported private key type");
            }

            if (fmt == ArchiveFormat.PKCS12)
            {
                var x509Arr = certs.Select(x =>
                {
                    using (var bio = BIO.MemoryBuffer())
                    {
                        bio.Write(x.Pem);
                        return(new X509Certificate(bio));
                    }
                }).ToArray();

                using (var key = CryptoKey.FromPrivateKey(rsaPk.Pem, null))
                {
                    var caStack = new OpenSSL.Core.Stack <X509Certificate>();
                    for (int i = 1; i < x509Arr.Length; ++i)
                    {
                        caStack.Add(x509Arr[i]);
                    }

                    using (var pfx = new PKCS12(password == string.Empty ? null : password, key, x509Arr[0], caStack))
                    {
                        using (var bio = BIO.MemoryBuffer())
                        {
                            pfx.Write(bio);
                            var count = (int)bio.BytesPending;
                            var array = bio.ReadBytes(count);
                            target.Write(array.Array, 0, count);
                        }
                    }
                }

                foreach (var x in x509Arr)
                {
                    x.Dispose();
                }
            }
            else
            {
                throw new NotSupportedException("unsupported archive format");
            }
        }
Beispiel #28
0
        // CreateArchive creates given format of archive to the destination.
        public async Task CreateArchive(ArchiveFormat format, string dst)
        {
            var prefix = Utils.BasePath(this.Repo.Path.TrimSuffix(".git")) + "/";
            var cmd    = new Command("archive",
                                     "--prefix=" + prefix,
                                     "--format=" + format.ToTypeString(),
                                     "-o", dst,
                                     this.ID.String());
            var result = await cmd.RunAsync(dir : this.Repo.Path);

            if (!string.IsNullOrEmpty(result.StdErr))
            {
                throw new Exception(result.StdErr);
            }
        }
Beispiel #29
0
 internal ArchiveEntry(IArchiveEntry archiveEntry, string archivePath, ArchiveFormat archiveFormat)
 {
     Index            = (uint)archiveEntry.Index;
     Path             = archiveEntry.FilePath;
     Size             = (ulong)archiveEntry.Size;
     Name             = System.IO.Path.GetFileName(archiveEntry.FilePath);
     CompressedSize   = 0; // Not supported in SevenZipSharp (yet)
     ModifiedDate     = archiveEntry.LastModifiedTime.GetValueOrDefault();
     IsEncrypted      = archiveEntry.IsEncrypted;
     IsFolder         = archiveEntry.IsDirectory;
     ArchivePath      = archivePath;
     Format           = archiveFormat;
     CRC              = archiveEntry.Crc;
     UnderlyingObject = archiveEntry;
 }
Beispiel #30
0
        private void OpenArchive(Stream data, string fname, ArchiveFormat format)
        {
            // Let's open the archive and add it to the stack
            ArchiveReader archive = Archive.Open(data, format);

            ArchiveInfo info = new ArchiveInfo();

            info.Format  = format;
            info.Archive = archive;

            openedArchives.Push(info);
            openedArchiveNames.Add((fname == String.Empty ? "Unnamed" : fname));

            Populate(info);
        }
Beispiel #31
0
        internal ArchiveEntry(IArchiveEntry archiveEntry, string archivePath, ArchiveFormat archiveFormat)
        {
            Index = (uint) archiveEntry.Index;
            Path = archiveEntry.FilePath;
            Size = (ulong)archiveEntry.Size;
			Name = System.IO.Path.GetFileName(archiveEntry.FilePath);
            CompressedSize = 0; // Not supported in SevenZipSharp (yet)
            ModifiedDate = archiveEntry.LastModifiedTime.GetValueOrDefault ();            
            IsEncrypted = archiveEntry.IsEncrypted;
            IsFolder = archiveEntry.IsDirectory;
            ArchivePath = archivePath;
            Format = archiveFormat;
            CRC = archiveEntry.Crc;
			UnderlyingObject = archiveEntry;
        }
Beispiel #32
0
        bool ReadDir(string root, long base_offset)
        {
            m_input.BaseStream.Position = base_offset;
            if (0x5542494C != m_input.ReadUInt32()) // 'LIBU'
            {
                return(false);
            }
            m_input.ReadInt32();
            int count = m_input.ReadInt32();

            if (!ArchiveFormat.IsSaneCount(count))
            {
                return(false);
            }
            if (m_dir.Capacity < m_dir.Count + count)
            {
                m_dir.Capacity = m_dir.Count + count;
            }

            long index_pos = base_offset + 0x10;

            for (int i = 0; i < count; ++i)
            {
                m_input.BaseStream.Position = index_pos;
                var  name         = ReadName();
                uint entry_size   = m_input.ReadUInt32();
                long entry_offset = base_offset + m_input.ReadInt64();
                index_pos = m_input.BaseStream.Position;
                bool has_extension = -1 != name.IndexOf('.');
                name = Path.Combine(root, name);
                if (!has_extension && ReadDir(name, entry_offset))
                {
                    continue;
                }

                var entry = FormatCatalog.Instance.Create <Entry> (name);
                entry.Offset = entry_offset;
                entry.Size   = entry_size;
                if (!entry.CheckPlacement(m_max_offset))
                {
                    return(false);
                }

                m_dir.Add(entry);
            }
            return(true);
        }
        public GetArchiveLinkRequest(string accountName, string repositoryName, Revision revision, ArchiveFormat format = ArchiveFormat.Zipball)
        {
            #region Preconditions

            if (accountName == null)
                throw new ArgumentNullException(nameof(accountName));

            if (repositoryName == null)
                throw new ArgumentNullException(nameof(repositoryName));

            #endregion

            AccountName = accountName;
            RepositoryName = repositoryName;
            Revision = revision;
            Format = format;
        }
Beispiel #34
0
 public PackIndexReader(PackOpener fmt, ArcView file, long index_offset)
 {
     m_fmt          = fmt;
     m_file         = file;
     m_pack_version = new Version(m_file.View.ReadByte(index_offset + 0xB) - '0',
                                  m_file.View.ReadByte(index_offset + 0xD) - '0');
     m_count = m_file.View.ReadInt32(index_offset + 0x10);
     if (!ArchiveFormat.IsSaneCount(m_count))
     {
         throw new InvalidFormatException();
     }
     m_index_offset = m_file.View.ReadInt64(index_offset + 0x14);
     if (index_offset < 0 || index_offset >= m_file.MaxOffset)
     {
         throw new InvalidFormatException();
     }
     m_index = m_file.CreateStream(m_index_offset);
     m_dir   = new List <Entry> (m_count);
 }
        /// <summary>
        /// Get an archive of a given repository's contents, in a specific format
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        public Task<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            return GetArchive(owner, name, archiveFormat, string.Empty);
        }
        /// <summary>
        /// Get an archive of a given repository's contents, using a specific format and reference
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        /// <returns>The binary contents of the archive</returns>
        public async Task<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference);

            var response = await Connection.Get<byte[]>(endpoint, TimeSpan.FromMinutes(60));

            return response.Body;
        }
Beispiel #37
0
 public IsfArchive(ArcView arc, ArchiveFormat impl, ICollection<Entry> dir, byte[] secret = null)
     : base(arc, impl, dir)
 {
     Secret = secret;
 }
        /// <summary>
        /// Get an archive of a given repository's contents, in a specific format
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        /// <param name="timeout"> Time span until timeout </param>
        /// <returns>The binary contents of the archive</returns>
        public IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.GreaterThanZero(timeout, "timeout");

            return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference, timeout).ToObservable();
        }
        public IObservable<string> GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            return _client.Repository.Content.GetArchiveLink(owner, name, archiveFormat, reference).ToObservable();
        }
Beispiel #40
0
 internal PscxSevenZipReader(PscxCmdlet command, FileInfo file, ArchiveFormat format) :
     base(command, file, format)
 {
     command.WriteDebug(String.Format("Created {0} reader for {1}.", format, file));
 }
Beispiel #41
0
 /// <summary>
 /// Returns the <see cref="Uri"/> for getting an archive of a given repository's contents, in a specific format
 /// </summary>
 /// <param name="repositoryId">The Id of the repository</param>
 /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
 /// <param name="reference">A valid Git reference.</param>
 /// <returns>The <see cref="Uri"/> for getting an archive of a given repository's contents, in a specific format</returns>
 public static Uri RepositoryArchiveLink(int repositoryId, ArchiveFormat archiveFormat, string reference)
 {
     return "repositories/{0}/{1}/{2}".FormatUri(repositoryId, archiveFormat.ToParameter(), reference);
 }
Beispiel #42
0
 public DxArchive(ArcView arc, ArchiveFormat impl, ICollection<Entry> dir, byte[] key)
     : base(arc, impl, dir)
 {
     Key = key;
 }
Beispiel #43
0
 public QlieArchive(ArcView arc, ArchiveFormat impl, ICollection<Entry> dir,
                     uint hash, byte[] key_data)
     : base(arc, impl, dir)
 {
     Hash = hash;
     GameKeyData = key_data;
 }
Beispiel #44
0
        private void OpenArchive(Stream data, string fname, ArchiveFormat format)
        {
            // Let's open the archive and add it to the stack
            ArchiveReader archive = Archive.Open(data, format);

            ArchiveInfo info = new ArchiveInfo();
            info.Format = format;
            info.Archive = archive;

            openedArchives.Push(info);
            openedArchiveNames.Add((fname == String.Empty ? "Unnamed" : fname));

            Populate(info);
        }
Beispiel #45
0
 public AzArchive(ArcView arc, ArchiveFormat impl, ICollection<Entry> dir, uint syskey, uint regkey)
     : base(arc, impl, dir)
 {
     SysenvKey = syskey;
     RegularKey = regkey;
 }
Beispiel #46
0
 public BdfArchive(ArcView arc, ArchiveFormat impl, ICollection<Entry> dir)
     : base(arc, impl, dir)
 {
 }
 /// <summary>
 /// Set the format for the generated archive. Currently only 'zip' is supported.
 /// </summary>
 public ArchiveParams TargetFormat(ArchiveFormat targetFormat)
 {
     this.m_targetFormat = targetFormat;
     return this;
 }
 /// <summary>
 /// Get an archive of a given repository's contents, using a specific format and reference
 /// </summary>
 /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
 /// <param name="owner">The owner of the repository</param>
 /// <param name="name">The name of the repository</param>
 /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
 /// <param name="reference">A valid Git reference.</param>
 /// <returns>A promise, containing the binary contents of the archive</returns>
 public IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference)
 {
     return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference).ToObservable();
 }
Beispiel #49
0
 public LuciArchive(ArcView arc, ArchiveFormat impl, ICollection<Entry> dir, EncryptionScheme scheme, LpkInfo info)
     : base(arc, impl, dir)
 {
     Info = info;
     Scheme = scheme;
 }
        /// <summary>
        /// Get an archive of a given repository's contents, in a specific format
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        /// <param name="timeout"> Time span until timeout </param>
        public async Task<byte[]> GetArchive(int repositoryId, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
        {
            Ensure.ArgumentNotNull(reference, "reference");
            Ensure.GreaterThanZero(timeout, "timeout");

            var endpoint = ApiUrls.RepositoryArchiveLink(repositoryId, archiveFormat, reference);

            var response = await Connection.Get<byte[]>(endpoint, timeout).ConfigureAwait(false);

            return response.Body;
        }
        /// <summary>
        /// Get an archive of a given repository's contents, in a specific format
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        /// <param name="timeout"> Time span until timeout </param>
        /// <returns>The binary contents of the archive</returns>
        public async Task<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.GreaterThanZero(timeout, "timeout");

            var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference);

            var response = await Connection.Get<byte[]>(endpoint, timeout).ConfigureAwait(false);

            return response.Body;
        }
        /// <summary>
        /// Get an archive of a given repository's contents, using a specific format and reference
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        public Task<byte[]> GetArchive(int repositoryId, ArchiveFormat archiveFormat, string reference)
        {
            Ensure.ArgumentNotNull(reference, "reference");

            return GetArchive(repositoryId, archiveFormat, reference, TimeSpan.FromMinutes(60));
        }
Beispiel #53
0
 public static Uri RepositoryArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference)
 {
     return "repos/{0}/{1}/{2}/{3}".FormatUri(owner, name, archiveFormat.ToParameter(), reference);
 }
        /// <summary>
        /// Get an archive of a given repository's contents, using a specific format and reference
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        public Task<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(reference, "reference");

            return GetArchive(owner, name, archiveFormat, reference, TimeSpan.FromMinutes(60));
        }
 /// <summary>
 /// Get an archive of a given repository's contents, in a specific format
 /// </summary>
 /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
 /// <param name="owner">The owner of the repository</param>
 /// <param name="name">The name of the repository</param>
 /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
 /// <returns>A promise, containing the binary contents of the archive</returns>
 public IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat)
 {
     return GetArchive(owner, name, archiveFormat, string.Empty);
 }
 /// <summary>
 /// Get an archive of a given repository's contents, in a specific format
 /// </summary>
 /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
 /// <param name="repositoryId">The Id of the repository</param>
 /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
 public Task<byte[]> GetArchive(int repositoryId, ArchiveFormat archiveFormat)
 {
     return GetArchive(repositoryId, archiveFormat, string.Empty);
 }
 /// <summary>
 /// Get an archive of a given repository's contents, using a specific format and reference
 /// </summary>
 /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
 /// <param name="owner">The owner of the repository</param>
 /// <param name="name">The name of the repository</param>
 /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
 /// <param name="reference">A valid Git reference.</param>
 /// <returns>A promise, containing the binary contents of the archive</returns>
 public IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference)
 {
     return GetArchive(owner, name, archiveFormat, reference, TimeSpan.FromMinutes(60));
 }
 public GetArchiveLinkRequest(string userName, string nameOfRepository, ArchiveFormat formatOfArchive, string @ref)
     : base(string.Format("/repos/{0}/{1}/{2}/{3}", userName, nameOfRepository, formatOfArchive.ToString().ToLower(), @ref))
 {
 }
 public IObservable<string> GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat)
 {
     return GetArchiveLink(owner, name, archiveFormat, string.Empty);
 }
        /// <summary>
        /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository.
        /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the 
        /// Location header to make a second GET request.
        /// Note: For private repositories, these links are temporary and expire quickly.
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
        /// <param name="reference">A valid Git reference.</param>
        /// <returns></returns>
        public Task<string> GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            return ApiConnection.GetRedirect(ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference));
        }