parent
282417c9af
commit
e9468cb0c8
|
@ -47,8 +47,6 @@ namespace BizHawk.Emulation.Common
|
|||
additionalInfo: additionalInfo,
|
||||
isBad: isBad);
|
||||
|
||||
// make sure id doesn't have a space, it is stored in the (space delimited) movie header!
|
||||
|
||||
void Option(string systemId, string id, in FirmwareFile ff, FirmwareOptionStatus status = FirmwareOptionStatus.Acceptable)
|
||||
{
|
||||
var option = new FirmwareOption(new(systemId, id), ff.Hash, ff.Size, ff.IsBad ? FirmwareOptionStatus.Bad : status);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public readonly struct FirmwareID
|
||||
|
@ -16,6 +19,11 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public FirmwareID(string system, string firmware)
|
||||
{
|
||||
static bool IsAllowedCharacter(char c)
|
||||
=> c is '-' or (>= '0' and <= '9') or (>= 'A' and <= 'Z') or '_' or (>= 'a' and <= 'z');
|
||||
const string ERR_MSG_INVALID_CHAR = "FWIDs must match /[-0-9A-Z_a-z]+/";
|
||||
if (!system.All(IsAllowedCharacter)) throw new ArgumentOutOfRangeException(paramName: system, actualValue: system, message: ERR_MSG_INVALID_CHAR);
|
||||
if (!firmware.All(IsAllowedCharacter)) throw new ArgumentOutOfRangeException(paramName: firmware, actualValue: firmware, message: ERR_MSG_INVALID_CHAR);
|
||||
System = system;
|
||||
Firmware = firmware;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue