コード例 #1
0
        public ReleaseManifest GetReleaseManifest()
        {
            byte[] data;
            using (WebClient wc = new WebClient())
            {
                data = wc.DownloadData($"{Program.API_BASE}projects/{this.Name}/releases/{this.Version}/releasemanifest");
            }

            var m = new ReleaseManifest();

            using (MemoryStream ms = new MemoryStream(data))
            {
                m.BranchName = this.Name;

                m.MagicHeaderInt = GetInt(ms);
                m.FileType = GetInt(ms);
                m.ItemCount = GetInt(ms);
                m.ReleaseVersion = GetInt(ms);
                m.ReleaseName = GetReleaseName(m.ReleaseVersion);

                DirectoryMetaData[] directoryMetaDatas = new DirectoryMetaData[GetInt(ms)];

                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    directoryMetaDatas[i] = new DirectoryMetaData(GetInt(ms),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms));
                }

                FileMetaData[] fileMetaDatas = new FileMetaData[GetInt(ms)];
                for (int i = 0; i < fileMetaDatas.Length; i++)
                {
                    fileMetaDatas[i] = new FileMetaData(GetInt(ms),
                            GetInt(ms),
                            GetBytes(ms, 16),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms));
                }
                String[] strs = new String[GetInt(ms)];
                int datasize = GetInt(ms); // ignored

                int c;
                int idx = 0;
                StringBuilder sb = new StringBuilder();
                while ((c = ms.ReadByte()) != -1)
                {
                    if (c == '\0')
                    {
                        strs[idx] = sb.ToString();
                        sb = new StringBuilder();
                        idx++;
                        continue;
                    }
                    sb.Append((char)c);
                }
                //assert(component.equals(strs[strs.length - 1]));

                // creating proper objects
                m.Directories = new Directory[directoryMetaDatas.Length];
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    m.Directories[i] = new Directory(strs[directoryMetaDatas[i].nameindex]);
                }
                // linking subdirectories
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    int start = directoryMetaDatas[i].subdirFirstIndex;
                    if (start == i) start++;
                    m.Directories[i].subdirs = new Directory[directoryMetaDatas[i].nsubdirs];

                    for (int j = 0; j < directoryMetaDatas[i].nsubdirs; j++)
                    {
                        m.Directories[i].subdirs[j] = m.Directories[start + j];
                        m.Directories[start + j].path = m.Directories[i].path + m.Directories[start + j].path;
                    }
                }
                m.Files = new ManifestFile[fileMetaDatas.Length];
                for (int i = 0; i < fileMetaDatas.Length; i++)
                {
                    FileMetaData meta = fileMetaDatas[i];
                    m.Files[i] = new ManifestFile(GetReleaseName(meta.release),
                            meta.release,
                            strs[meta.nameindex],
                            meta.checksum, meta.sizeCompressed,
                            meta.fileType, meta.sizeUncompressed,
                            meta.unknownInt3, meta.unknownInt4);
                }
                // linking files to directories
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    int start = directoryMetaDatas[i].firstfileIndex;
                    m.Directories[i].files = new ManifestFile[directoryMetaDatas[i].fileCount];

                    for (int j = 0; j < directoryMetaDatas[i].fileCount; j++)
                    {
                        m.Directories[i].files[j] = m.Files[start + j];
                        m.Files[start + j].path = m.Directories[i].path;
                    }
                }
                m.FileDictionary = new Dictionary<string, ManifestFile>();
                foreach (ManifestFile fi in m.Files)
                {
                    m.FileDictionary[fi.path + fi.name] =  fi;
                }
            }

        

            return m;

            

        }
コード例 #2
0
        public ReleaseManifest GetReleaseManifest()
        {
            byte[] data;
            using (WebClient wc = new WebClient())
            {
                data = wc.DownloadData($"{Program.API_BASE}projects/{this.Name}/releases/{this.Version}/releasemanifest");
            }

            var m = new ReleaseManifest();

            using (MemoryStream ms = new MemoryStream(data))
            {
                m.BranchName = this.Name;

                m.MagicHeaderInt = GetInt(ms);
                m.FileType       = GetInt(ms);
                m.ItemCount      = GetInt(ms);
                m.ReleaseVersion = GetInt(ms);
                m.ReleaseName    = GetReleaseName(m.ReleaseVersion);

                DirectoryMetaData[] directoryMetaDatas = new DirectoryMetaData[GetInt(ms)];

                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    directoryMetaDatas[i] = new DirectoryMetaData(GetInt(ms),
                                                                  GetInt(ms),
                                                                  GetInt(ms),
                                                                  GetInt(ms),
                                                                  GetInt(ms));
                }

                FileMetaData[] fileMetaDatas = new FileMetaData[GetInt(ms)];
                for (int i = 0; i < fileMetaDatas.Length; i++)
                {
                    fileMetaDatas[i] = new FileMetaData(GetInt(ms),
                                                        GetInt(ms),
                                                        GetBytes(ms, 16),
                                                        GetInt(ms),
                                                        GetInt(ms),
                                                        GetInt(ms),
                                                        GetInt(ms),
                                                        GetInt(ms));
                }
                String[] strs     = new String[GetInt(ms)];
                int      datasize = GetInt(ms); // ignored

                int           c;
                int           idx = 0;
                StringBuilder sb  = new StringBuilder();
                while ((c = ms.ReadByte()) != -1)
                {
                    if (c == '\0')
                    {
                        strs[idx] = sb.ToString();
                        sb        = new StringBuilder();
                        idx++;
                        continue;
                    }
                    sb.Append((char)c);
                }
                //assert(component.equals(strs[strs.length - 1]));

                // creating proper objects
                m.Directories = new Directory[directoryMetaDatas.Length];
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    m.Directories[i] = new Directory(strs[directoryMetaDatas[i].nameindex]);
                }
                // linking subdirectories
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    int start = directoryMetaDatas[i].subdirFirstIndex;
                    if (start == i)
                    {
                        start++;
                    }
                    m.Directories[i].subdirs = new Directory[directoryMetaDatas[i].nsubdirs];

                    for (int j = 0; j < directoryMetaDatas[i].nsubdirs; j++)
                    {
                        m.Directories[i].subdirs[j]   = m.Directories[start + j];
                        m.Directories[start + j].path = m.Directories[i].path + m.Directories[start + j].path;
                    }
                }
                m.Files = new ManifestFile[fileMetaDatas.Length];
                for (int i = 0; i < fileMetaDatas.Length; i++)
                {
                    FileMetaData meta = fileMetaDatas[i];
                    m.Files[i] = new ManifestFile(GetReleaseName(meta.release),
                                                  meta.release,
                                                  strs[meta.nameindex],
                                                  meta.checksum, meta.sizeCompressed,
                                                  meta.fileType, meta.sizeUncompressed,
                                                  meta.unknownInt3, meta.unknownInt4);
                }
                // linking files to directories
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    int start = directoryMetaDatas[i].firstfileIndex;
                    m.Directories[i].files = new ManifestFile[directoryMetaDatas[i].fileCount];

                    for (int j = 0; j < directoryMetaDatas[i].fileCount; j++)
                    {
                        m.Directories[i].files[j] = m.Files[start + j];
                        m.Files[start + j].path   = m.Directories[i].path;
                    }
                }
                m.FileDictionary = new Dictionary <string, ManifestFile>();
                foreach (ManifestFile fi in m.Files)
                {
                    m.FileDictionary[fi.path + fi.name] = fi;
                }
            }



            return(m);
        }