11using System ;
22using System . IO ;
33using System . IO . Abstractions ;
4+ using System . Runtime . CompilerServices ;
5+ using System . Runtime . InteropServices ;
46using System . Xml ;
57using System . Xml . Linq ;
68using Microsoft . Extensions . DependencyInjection ;
@@ -15,9 +17,6 @@ namespace PG.StarWarsGame.Files.XML.Parsers;
1517public abstract class PetroglyphXmlFileParserBase ( IServiceProvider serviceProvider , IXmlParserErrorReporter ? errorReporter )
1618 : PetroglyphXmlParserBase ( errorReporter )
1719{
18- protected readonly IServiceProvider ServiceProvider =
19- serviceProvider ?? throw new ArgumentNullException ( nameof ( serviceProvider ) ) ;
20-
2120 protected readonly IFileSystem FileSystem = serviceProvider . GetRequiredService < IFileSystem > ( ) ;
2221
2322 protected virtual bool LoadLineInfo => true ;
@@ -62,18 +61,24 @@ protected XElement GetRootElement(Stream xmlStream, out string fileName)
6261
6362 return root ;
6463 }
65-
64+
6665 private string GetStrippedFileName ( string filePath )
6766 {
6867 if ( ! FileSystem . Path . IsPathFullyQualified ( filePath ) )
6968 return filePath ;
70-
71- var pathPartIndex = filePath . LastIndexOf ( "DATA \\ XML \\ " , StringComparison . OrdinalIgnoreCase ) ;
69+
70+ var pathPartIndex = filePath . LastIndexOf ( GetXmlDataFolder ( ) , StringComparison . OrdinalIgnoreCase ) ;
7271
7372 if ( pathPartIndex == - 1 )
7473 return filePath ;
7574
76- return filePath . Substring ( pathPartIndex ) ;
75+ return filePath [ pathPartIndex ..] ;
76+
77+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
78+ static string GetXmlDataFolder ( )
79+ {
80+ return RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? @"DATA\XML\" : "DATA/XML/" ;
81+ }
7782 }
7883
7984
0 commit comments