[gnome-games] playstation: Parse only the basename of the executable



commit 8041acd06cb71e6e586d9e92ee289a03e1e634cf
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Sep 7 08:23:55 2017 +0200

    playstation: Parse only the basename of the executable
    
    Strip anything before '\' or '/' from the executable filename parsed
    from a PlayStation disc. This allows to better parse the disc's ID.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787396

 plugins/playstation/src/playstation-header.vala |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/plugins/playstation/src/playstation-header.vala b/plugins/playstation/src/playstation-header.vala
index b63c447..24591be 100644
--- a/plugins/playstation/src/playstation-header.vala
+++ b/plugins/playstation/src/playstation-header.vala
@@ -38,7 +38,10 @@ private class Games.PlayStationHeader : Object {
        }
 
        private string? parse_id_from_exe (string exe) throws Error {
-               var disc_id = exe.strip ();
+               // Add 1 to either turn -1 into 0 or to skip the found character.
+               var start = int.max (exe.last_index_of ("\\"), exe.last_index_of ("/")) + 1;
+               var disc_id = exe.offset (start);
+               disc_id = disc_id.strip ();
                disc_id = disc_id.split (";")[0];
                disc_id = disc_id.replace ("_", "-");
                disc_id = disc_id.replace (".", "");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]