private async Task PrintFilesDownload(Task downloadTask, FileDownloadStatus[] states)
        {
            bool exit = false;

            while (true)
            {
                int    finished   = states.Where(s => s.Downloaded == s.TotalSize).Count();
                long   total      = states.Select(s => s.TotalSize).Sum();
                long   current    = states.Select(s => s.Downloaded).Sum();
                double percentage = current / (double)total * 100;
                Printer?.Print($"\r [{percentage:0.00} %] {MiscUtils.BytesToString(current)}/{MiscUtils.BytesToString(total)} ({finished} / {states.Length} Files)   ");

                if (exit)
                {
                    Printer?.PrintLine("");
                    break;
                }

                if (await Task.WhenAny(downloadTask, Task.Delay(500)) == downloadTask)
                {
                    await downloadTask;
                    exit = true;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Reads a buffer containing the header of a main volume file.
        /// </summary>
        /// <param name="header"></param>
        /// <returns></returns>
        private bool ReadHeader(Span <byte> header)
        {
            GTVolumeHeader volHeader = GTVolumeHeader.FromStream(header);

            if (volHeader is null)
            {
                return(false);
            }

            Program.Log($"[>] Table of Contents Entry Index: {volHeader.TOCEntryIndex}");
            Program.Log($"[>] TOC Size: {volHeader.CompressedTOCSize} bytes ({volHeader.TOCSize} decompressed)");
            Program.Log($"[>] Total Volume Size: {MiscUtils.BytesToString((long)volHeader.TotalVolumeSize)}");
            Program.Log($"[>] Title ID: '{volHeader.TitleID}'");
            VolumeHeader = volHeader;

            return(true);
        }