A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using System;
5using System.IO;
6using osu.Framework.Platform;
7
8namespace osu.Framework.Testing
9{
10 /// <summary>
11 /// A temporary storage that can be used for testing purposes.
12 /// Writes files to the OS temporary directory and cleans up on disposal.
13 /// </summary>
14 public class TemporaryNativeStorage : NativeStorage, IDisposable
15 {
16 public TemporaryNativeStorage(string path, GameHost host = null)
17 : base(Path.Combine(TestRunHeadlessGameHost.TemporaryTestDirectory, path), host)
18 {
19 // create directory
20 GetFullPath("./", true);
21 }
22
23 public void Dispose()
24 {
25 try
26 {
27 DeleteDirectory(string.Empty);
28 }
29 catch
30 {
31 }
32 }
33 }
34}