@@ -10,16 +10,12 @@ namespace plugin_OpenVR.Utils;
1010[ SuppressMessage ( "ReSharper" , "CollectionNeverUpdated.Global" ) ]
1111internal class OpenVrPaths
1212{
13- #if WINDOWS
14- public static readonly string Path =
13+ public static string Path => OperatingSystem . IsWindows ( ) ?
1514 Environment . ExpandEnvironmentVariables ( System . IO . Path . Combine (
16- "%LocalAppData%" , "openvr" , "openvrpaths.vrpath" ) ) ;
17- #else
18- public static readonly string Path =
15+ "%LocalAppData%" , "openvr" , "openvrpaths.vrpath" ) ) :
1916 System . IO . Path . Combine (
2017 Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ,
2118 ".config" , "openvr" , "openvrpaths.vrpath" ) ;
22- #endif
2319
2420 public static OpenVrPaths Read ( )
2521 {
@@ -60,11 +56,13 @@ public void Write()
6056#pragma warning restore 0649
6157}
6258
63- #if WINDOWS
6459public static class PathUtils
6560{
66- public static string GetShortName ( string sLongFileName )
61+ private static string GetShortName ( string sLongFileName )
6762 {
63+ if ( ! OperatingSystem . IsWindows ( ) )
64+ return sLongFileName ;
65+
6866 var buffer = new StringBuilder ( 259 ) ;
6967 if ( GetShortPathName ( sLongFileName , buffer , buffer . Capacity ) == 0 )
7068 throw new System . ComponentModel . Win32Exception ( ) ;
@@ -79,6 +77,9 @@ public static string ShortPath(this string path)
7977 {
8078 try
8179 {
80+ if ( ! OperatingSystem . IsWindows ( ) )
81+ return path ;
82+
8283 var result = GetShortName ( path ) ;
8384 return string . IsNullOrEmpty ( result ) ? path : result ;
8485 }
@@ -88,17 +89,3 @@ public static string ShortPath(this string path)
8889 }
8990 }
9091}
91- #else
92- public static class PathUtils
93- {
94- public static string GetShortName ( string sLongFileName )
95- {
96- return sLongFileName ;
97- }
98-
99- public static string ShortPath ( this string path )
100- {
101- return path ;
102- }
103- }
104- #endif
0 commit comments