@@ -16,7 +16,6 @@ You should have received a copy of the SKL Standard License 1.0
1616*/
1717using System ;
1818
19- using System . IO ;
2019using System . Collections . Generic ;
2120using System . Linq ;
2221
@@ -39,11 +38,11 @@ select a
3938
4039 internal static string UpdateIfNeeded ( string name , string sourceFilename , string targetFilename )
4140 {
42- sourceFilename = Path . Combine ( SanityLib . CalcGameData ( ) , sourceFilename ) ;
43- targetFilename = Path . Combine ( SanityLib . CalcGameData ( ) , targetFilename ) ;
44- if ( File . Exists ( sourceFilename ) )
41+ sourceFilename = System . IO . Path . Combine ( SanityLib . CalcGameData ( ) , sourceFilename ) ;
42+ targetFilename = System . IO . Path . Combine ( SanityLib . CalcGameData ( ) , targetFilename ) ;
43+ if ( System . IO . File . Exists ( sourceFilename ) )
4544 {
46- if ( File . Exists ( targetFilename ) )
45+ if ( System . IO . File . Exists ( targetFilename ) )
4746 {
4847 {
4948 System . Diagnostics . FileVersionInfo sourceVersionInfo = System . Diagnostics . FileVersionInfo . GetVersionInfo ( sourceFilename ) ;
@@ -57,18 +56,18 @@ internal static string UpdateIfNeeded(string name, string sourceFilename, string
5756 if ( ! sane )
5857 {
5958 Log . info ( "File {0} is not compatible with {1}. This is going to cause trouble, replacing it!" , targetFilename , name ) ;
60- File . Delete ( targetFilename ) ; // Remove the file and update it no matter what!
61- return SanityLib . Update ( name , sourceFilename , targetFilename ) ;
59+ Delete ( targetFilename ) ; // Remove the file and update it no matter what!
60+ return Update ( name , sourceFilename , targetFilename ) ;
6261 }
6362 }
6463 {
6564 System . Reflection . Assembly sourceAsm = System . Reflection . Assembly . LoadFile ( sourceFilename ) ;
6665 System . Reflection . Assembly targetAsm = System . Reflection . Assembly . LoadFile ( targetFilename ) ;
6766 if ( ! sourceAsm . GetName ( ) . Version . Equals ( targetAsm . GetName ( ) . Version ) )
68- return SanityLib . Update ( name , sourceFilename , targetFilename ) ;
67+ return Update ( name , sourceFilename , targetFilename ) ;
6968 else
7069 {
71- File . Delete ( sourceFilename ) ;
70+ Delete ( sourceFilename ) ;
7271 return null ;
7372 }
7473 }
@@ -83,8 +82,9 @@ private static string Update(string name, string sourceFilename, string targetFi
8382 {
8483 try
8584 {
86- File . Copy ( sourceFilename , targetFilename ) ;
87- File . Delete ( sourceFilename ) ;
85+ Copy ( sourceFilename , targetFilename ) ;
86+ Log . dbg ( "Deleting {0}" , sourceFilename ) ;
87+ Delete ( sourceFilename ) ;
8888 return string . Format ( "{0} was updated." , name ) ;
8989 }
9090 catch ( Exception e )
@@ -94,19 +94,31 @@ private static string Update(string name, string sourceFilename, string targetFi
9494 }
9595 }
9696
97+ private static void Copy ( string sourceFilename , string targetFilename )
98+ {
99+ Log . dbg ( "Copying {0} to {1}" , sourceFilename , targetFilename ) ;
100+ System . IO . File . Copy ( sourceFilename , targetFilename ) ;
101+ }
102+
103+ private static void Delete ( string filename )
104+ {
105+ Log . dbg ( "Deleting {0}" , filename ) ;
106+ System . IO . File . Delete ( filename ) ;
107+ }
108+
97109 private static string GAMEDATA = null ;
98110 private static string CalcGameData ( )
99111 {
100112 if ( null != GAMEDATA ) return GAMEDATA ;
101113 System . Reflection . Assembly asm = System . Reflection . Assembly . GetAssembly ( typeof ( UnityEngine . MonoBehaviour ) ) ;
102- string path = Path . GetDirectoryName ( asm . Location ) ;
103- string candidate = Path . Combine ( path , "GameData" ) ;
114+ string path = System . IO . Path . GetDirectoryName ( asm . Location ) ;
115+ string candidate = System . IO . Path . Combine ( path , "GameData" ) ;
104116 try
105117 {
106- while ( ! Directory . Exists ( candidate ) )
118+ while ( ! System . IO . Directory . Exists ( candidate ) )
107119 {
108- path = Path . GetDirectoryName ( path ) ;
109- candidate = Path . Combine ( path , "GameData" ) ;
120+ path = System . IO . Path . GetDirectoryName ( path ) ;
121+ candidate = System . IO . Path . Combine ( path , "GameData" ) ;
110122 }
111123 Log . dbg ( "GameData found on {0}" , GAMEDATA ) ;
112124 return ( GAMEDATA = candidate ) ;
0 commit comments