@@ -143,10 +143,10 @@ public override string HandleDataTable(UXFDataTable table, string experiment, st
143
143
Directory . CreateDirectory ( directory ) ;
144
144
string savePath = Path . Combine ( directory , string . Format ( "{0}.csv" , dataName ) ) ;
145
145
146
- if ( verboseDebug ) Debug . LogFormat ( "Queuing save of file: {0}" , savePath ) ;
146
+ if ( verboseDebug ) Debug . LogFormat ( "Queuing save of file: {0}" , savePath ) ;
147
147
148
148
ManageInWorker ( ( ) => { File . WriteAllLines ( savePath , lines ) ; } ) ;
149
- return savePath ;
149
+ return GetRelativePath ( storagePath , savePath ) ; ;
150
150
}
151
151
152
152
public override string HandleJSONSerializableObject ( List < object > serializableObject , string experiment , string ppid , int sessionNum , string dataName , UXFDataType dataType , int optionalTrialNum = 0 )
@@ -163,7 +163,7 @@ public override string HandleJSONSerializableObject(List<object> serializableObj
163
163
if ( verboseDebug ) Debug . LogFormat ( "Queuing save of file: {0}" , savePath ) ;
164
164
165
165
ManageInWorker ( ( ) => { File . WriteAllText ( savePath , text ) ; } ) ;
166
- return savePath ;
166
+ return GetRelativePath ( storagePath , savePath ) ; ;
167
167
}
168
168
169
169
public override string HandleJSONSerializableObject ( Dictionary < string , object > serializableObject , string experiment , string ppid , int sessionNum , string dataName , UXFDataType dataType , int optionalTrialNum = 0 )
@@ -177,10 +177,10 @@ public override string HandleJSONSerializableObject(Dictionary<string, object> s
177
177
Directory . CreateDirectory ( directory ) ;
178
178
string savePath = Path . Combine ( directory , string . Format ( "{0}.json" , dataName ) ) ;
179
179
180
- if ( verboseDebug ) Debug . LogFormat ( "Queuing save of file: {0}" , savePath ) ;
180
+ if ( verboseDebug ) Debug . LogFormat ( "Queuing save of file: {0}" , savePath ) ;
181
181
182
182
ManageInWorker ( ( ) => { File . WriteAllText ( savePath , text ) ; } ) ;
183
- return savePath ;
183
+ return GetRelativePath ( storagePath , savePath ) ; ;
184
184
}
185
185
186
186
public override string HandleText ( string text , string experiment , string ppid , int sessionNum , string dataName , UXFDataType dataType , int optionalTrialNum = 0 )
@@ -192,10 +192,10 @@ public override string HandleText(string text, string experiment, string ppid, i
192
192
Directory . CreateDirectory ( directory ) ;
193
193
string savePath = Path . Combine ( directory , string . Format ( "{0}.txt" , dataName ) ) ;
194
194
195
- if ( verboseDebug ) Debug . LogFormat ( "Queuing save of file: {0}" , savePath ) ;
195
+ if ( verboseDebug ) Debug . LogFormat ( "Queuing save of file: {0}" , savePath ) ;
196
196
197
197
ManageInWorker ( ( ) => { File . WriteAllText ( savePath , text ) ; } ) ;
198
- return savePath ;
198
+ return GetRelativePath ( storagePath , savePath ) ; ;
199
199
}
200
200
201
201
public override string HandleBytes ( byte [ ] bytes , string experiment , string ppid , int sessionNum , string dataName , UXFDataType dataType , int optionalTrialNum = 0 )
@@ -207,10 +207,10 @@ public override string HandleBytes(byte[] bytes, string experiment, string ppid,
207
207
Directory . CreateDirectory ( directory ) ;
208
208
string savePath = Path . Combine ( directory , string . Format ( "{0}.txt" , dataName ) ) ;
209
209
210
- if ( verboseDebug ) Debug . LogFormat ( "Queuing save of file: {0}" , savePath ) ;
210
+ if ( verboseDebug ) Debug . LogFormat ( "Queuing save of file: {0}" , savePath ) ;
211
211
212
212
ManageInWorker ( ( ) => { File . WriteAllBytes ( savePath , bytes ) ; } ) ;
213
- return savePath ;
213
+ return GetRelativePath ( storagePath , savePath ) ;
214
214
}
215
215
216
216
@@ -243,6 +243,20 @@ public override void CleanUp()
243
243
bq . Enqueue ( doNothing ) ; // ensures bq breaks from foreach loop
244
244
parallelThread . Join ( ) ;
245
245
}
246
+
247
+ public static string GetRelativePath ( string relativeToDirectory , string path )
248
+ {
249
+ relativeToDirectory = Path . GetFullPath ( relativeToDirectory ) ;
250
+ if ( ! relativeToDirectory . EndsWith ( "\\ " ) ) relativeToDirectory += "\\ " ;
251
+
252
+ path = Path . GetFullPath ( path ) ;
253
+
254
+ Uri path1 = new Uri ( relativeToDirectory ) ;
255
+ Uri path2 = new Uri ( path ) ;
256
+
257
+ Uri diff = path1 . MakeRelativeUri ( path2 ) ;
258
+ return diff . OriginalString ;
259
+ }
246
260
}
247
261
248
262
0 commit comments