[gnome-games] playstation: Add PlayStationHeader.is_a_disc_id()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] playstation: Add PlayStationHeader.is_a_disc_id()
- Date: Sun, 28 Aug 2016 07:39:04 +0000 (UTC)
commit c81da85ecf4c596d7d9548471245071770d769ce
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sun Aug 28 09:27:33 2016 +0200
playstation: Add PlayStationHeader.is_a_disc_id()
This allows to be more sure we found a valid disc ID and hence that the
header is valid.
https://bugzilla.gnome.org/show_bug.cgi?id=770470
plugins/playstation/src/playstation-header.vala | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/plugins/playstation/src/playstation-header.vala b/plugins/playstation/src/playstation-header.vala
index ae02b3b..762b824 100644
--- a/plugins/playstation/src/playstation-header.vala
+++ b/plugins/playstation/src/playstation-header.vala
@@ -8,6 +8,9 @@ private class Games.PlayStationHeader : Object {
private const string BOOT_MAGIC_VALUE = "BOOT";
private const string[] IDS = { "SLUS", "SCUS", "SLES", "SCES", "SLPS", "SLPM", "SCPS" };
+ private const size_t DISC_ID_SIZE = 10;
+
+ private static Regex disc_id_regex;
private string _disc_id;
public string disc_id {
@@ -49,7 +52,8 @@ private class Games.PlayStationHeader : Object {
raw_id = raw_id.replace (".", "");
raw_id = (id + raw_id).up ();
- return raw_id;
+ if (is_a_disc_id (raw_id))
+ return raw_id;
}
return null;
@@ -64,4 +68,11 @@ private class Games.PlayStationHeader : Object {
return null;
}
+
+ private static bool is_a_disc_id (string disc_id) {
+ if (disc_id_regex == null)
+ disc_id_regex = /[A-Z]{4}-\d{5}/;
+
+ return disc_id_regex.match (disc_id);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]