コード例 #1
0
        /// <summary>
        /// Write out Game start using the supplied StreamWriter
        /// </summary>
        /// <param name="svw">SeparatedValueWriter to output to</param>
        /// <param name="datItem">DatItem object to be output</param>
        private void WriteDatItem(SeparatedValueWriter svw, DatItem datItem)
        {
            // No game should start with a path separator
            datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);

            // Pre-process the item name
            ProcessItemName(datItem, true);

            // Build the state
            switch (datItem.ItemType)
            {
            case ItemType.Rom:
                var rom = datItem as Rom;

                string[] fields = new string[]
                {
                    rom.SHA256 ?? string.Empty,
                    $"{rom.Machine.Name ?? string.Empty}/",
                    rom.Name ?? string.Empty,
                    rom.SHA1 ?? string.Empty,
                    rom.MD5 ?? string.Empty,
                    rom.CRC ?? string.Empty,
                };

                svw.WriteValues(fields);

                break;
            }

            svw.Flush();
        }
コード例 #2
0
 /// <summary>
 /// Write a single set of statistics
 /// </summary>
 /// <param name="svw">SeparatedValueWriter to write to</param>
 /// <param name="stat">DatStatistics object to write out</param>
 /// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
 /// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
 private void WriteIndividual(SeparatedValueWriter svw, DatStatistics stat, bool baddumpCol, bool nodumpCol)
 {
     string[] values = new string[]
     {
         stat.DisplayName,
         stat.Statistics.TotalSize.ToString(),
         stat.MachineCount.ToString(),
         stat.Statistics.RomCount.ToString(),
         stat.Statistics.DiskCount.ToString(),
         stat.Statistics.CRCCount.ToString(),
         stat.Statistics.MD5Count.ToString(),
         stat.Statistics.SHA1Count.ToString(),
         stat.Statistics.SHA256Count.ToString(),
         stat.Statistics.SHA384Count.ToString(),
         stat.Statistics.SHA512Count.ToString(),
         baddumpCol ? stat.Statistics.BaddumpCount.ToString() : string.Empty,
         nodumpCol ? stat.Statistics.NodumpCount.ToString() : string.Empty,
     };
     svw.WriteValues(values);
     svw.Flush();
 }
コード例 #3
0
        /// <summary>
        /// Write out Game start using the supplied StreamWriter
        /// </summary>
        /// <param name="svw">SeparatedValueWriter to output to</param>
        /// <param name="datItem">DatItem object to be output</param>
        /// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
        private void WriteDatItem(SeparatedValueWriter svw, DatItem datItem)
        {
            // No game should start with a path separator
            datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);

            // Pre-process the item name
            ProcessItemName(datItem, true);

            // Build the state
            switch (datItem.ItemType)
            {
            case ItemType.Rom:
                var      rom    = datItem as Rom;
                string[] fields = new string[]
                {
                    rom.Machine.Name,
                    rom.Machine.Description,
                    Header.FileName,
                    rom.Machine.CloneOf,
                    rom.Machine.Year,
                    rom.Machine.Manufacturer,
                    rom.Machine.Category,
                    rom.Machine.Players,
                    rom.Machine.Rotation,
                    rom.Machine.Control,
                    rom.ItemStatus.ToString(),
                    rom.Machine.DisplayCount,
                    rom.Machine.DisplayType,
                    rom.AltName,
                    rom.AltTitle,
                    rom.Machine.Comment,
                    rom.Machine.Buttons,
                };

                svw.WriteValues(fields);
                break;
            }

            svw.Flush();
        }
コード例 #4
0
        /// <summary>
        /// Write out DatItem using the supplied StreamWriter
        /// </summary>
        /// <param name="svw">SeparatedValueWriter to output to</param>
        /// <param name="datItem">DatItem object to be output</param>
        private void WriteDatItem(SeparatedValueWriter svw, DatItem datItem)
        {
            // Separated values should only output Rom and Disk
            if (datItem.ItemType != ItemType.Disk && datItem.ItemType != ItemType.Rom)
            {
                return;
            }

            // Build the state
            // TODO: Can we have some way of saying what fields to write out? Support for read extends to all fields now
            string[] fields = new string[14]; // 18;
            fields[0] = Header.FileName;
            fields[1] = Header.Name;
            fields[2] = Header.Description;
            fields[3] = datItem.Machine.Name;
            fields[4] = datItem.Machine.Description;

            switch (datItem.ItemType)
            {
            case ItemType.Disk:
                var disk = datItem as Disk;
                fields[5]  = "disk";
                fields[6]  = string.Empty;
                fields[7]  = disk.Name;
                fields[8]  = string.Empty;
                fields[9]  = string.Empty;
                fields[10] = disk.MD5?.ToLowerInvariant();
                //fields[11] = string.Empty;
                fields[11] = disk.SHA1?.ToLowerInvariant();
                fields[12] = string.Empty;
                //fields[13] = string.Empty;
                //fields[14] = string.Empty;
                //fields[15] = string.Empty;
                fields[13] = disk.ItemStatus.ToString();
                break;

            case ItemType.Media:
                var media = datItem as Media;
                fields[5]  = "media";
                fields[6]  = string.Empty;
                fields[7]  = media.Name;
                fields[8]  = string.Empty;
                fields[9]  = string.Empty;
                fields[10] = media.MD5?.ToLowerInvariant();
                //fields[11] = string.Empty;
                fields[11] = media.SHA1?.ToLowerInvariant();
                fields[12] = media.SHA256?.ToLowerInvariant();
                //fields[13] = string.Empty;
                //fields[14] = string.Empty;
                //fields[15] = media.SpamSum?.ToLowerInvariant();
                fields[13] = string.Empty;
                break;

            case ItemType.Rom:
                var rom = datItem as Rom;
                fields[5]  = "rom";
                fields[6]  = rom.Name;
                fields[7]  = string.Empty;
                fields[8]  = rom.Size?.ToString();
                fields[9]  = rom.CRC?.ToLowerInvariant();
                fields[10] = rom.MD5?.ToLowerInvariant();
                //fields[11] = rom.RIPEMD160?.ToLowerInvariant();
                fields[11] = rom.SHA1?.ToLowerInvariant();
                fields[12] = rom.SHA256?.ToLowerInvariant();
                //fields[13] = rom.SHA384?.ToLowerInvariant();
                //fields[14] = rom.SHA512?.ToLowerInvariant();
                //fields[15] = rom.SpamSum?.ToLowerInvariant();
                fields[13] = rom.ItemStatus.ToString();
                break;
            }

            svw.WriteString(CreatePrefixPostfix(datItem, true));
            svw.WriteValues(fields, false);
            svw.WriteString(CreatePrefixPostfix(datItem, false));
            svw.WriteLine();

            svw.Flush();
        }
コード例 #5
0
        /// <summary>
        /// Write out DatItem using the supplied SeparatedValueWriter
        /// </summary>
        /// <param name="svw">SeparatedValueWriter to output to</param>
        /// <param name="datItem">DatItem object to be output</param>
        private void WriteDatItem(SeparatedValueWriter svw, DatItem datItem)
        {
            // Build the state
            string[] fields = new string[2];

            // Get the name field
            string name = string.Empty;

            switch (datItem.ItemType)
            {
            case ItemType.Disk:
                var disk = datItem as Disk;
                if (Header.GameName)
                {
                    name = $"{disk.Machine.Name}{Path.DirectorySeparatorChar}";
                }

                name += disk.Name;
                break;

            case ItemType.Media:
                var media = datItem as Media;
                if (Header.GameName)
                {
                    name = $"{media.Machine.Name}{Path.DirectorySeparatorChar}";
                }

                name += media.Name;
                break;

            case ItemType.Rom:
                var rom = datItem as Rom;
                if (Header.GameName)
                {
                    name = $"{rom.Machine.Name}{Path.DirectorySeparatorChar}";
                }

                name += rom.Name;
                break;
            }

            // Get the hash field and set final fields
            switch (_hash)
            {
            case Hash.CRC:
                switch (datItem.ItemType)
                {
                case ItemType.Rom:
                    var rom = datItem as Rom;
                    fields[0] = name;
                    fields[1] = rom.CRC;
                    break;
                }

                break;

            case Hash.MD5:
                switch (datItem.ItemType)
                {
                case ItemType.Disk:
                    var disk = datItem as Disk;
                    fields[0] = disk.MD5;
                    fields[1] = name;
                    break;

                case ItemType.Media:
                    var media = datItem as Media;
                    fields[0] = media.MD5;
                    fields[1] = name;
                    break;

                case ItemType.Rom:
                    var rom = datItem as Rom;
                    fields[0] = rom.MD5;
                    fields[1] = name;
                    break;
                }

                break;

            case Hash.SHA1:
                switch (datItem.ItemType)
                {
                case ItemType.Disk:
                    var disk = datItem as Disk;
                    fields[0] = disk.SHA1;
                    fields[1] = name;
                    break;

                case ItemType.Media:
                    var media = datItem as Media;
                    fields[0] = media.SHA1;
                    fields[1] = name;
                    break;

                case ItemType.Rom:
                    var rom = datItem as Rom;
                    fields[0] = rom.SHA1;
                    fields[1] = name;
                    break;
                }

                break;

            case Hash.SHA256:
                switch (datItem.ItemType)
                {
                case ItemType.Media:
                    var media = datItem as Media;
                    fields[0] = media.SHA256;
                    fields[1] = name;
                    break;

                case ItemType.Rom:
                    var rom = datItem as Rom;
                    fields[0] = rom.SHA256;
                    fields[1] = name;
                    break;
                }

                break;

            case Hash.SHA384:
                switch (datItem.ItemType)
                {
                case ItemType.Rom:
                    var rom = datItem as Rom;
                    fields[0] = rom.SHA384;
                    fields[1] = name;
                    break;
                }

                break;

            case Hash.SHA512:
                switch (datItem.ItemType)
                {
                case ItemType.Rom:
                    var rom = datItem as Rom;
                    fields[0] = rom.SHA512;
                    fields[1] = name;
                    break;
                }

                break;

            case Hash.SpamSum:
                switch (datItem.ItemType)
                {
                case ItemType.Media:
                    var media = datItem as Media;
                    fields[0] = media.SpamSum;
                    fields[1] = name;
                    break;

                case ItemType.Rom:
                    var rom = datItem as Rom;
                    fields[0] = rom.SpamSum;
                    fields[1] = name;
                    break;
                }

                break;
            }

            // If we had at least one field filled in
            if (!string.IsNullOrEmpty(fields[0]) || !string.IsNullOrEmpty(fields[1]))
            {
                svw.WriteValues(fields);
            }

            svw.Flush();
        }