Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MicroThreadFileProvider.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.IO;
5 using SiliconStudio.Core.IO;
6 using SiliconStudio.Core.MicroThreading;
7 
8 namespace SiliconStudio.BuildEngine
9 {
11  {
12  public MicroThreadLocal<IVirtualFileProvider> ThreadLocal = new MicroThreadLocal<IVirtualFileProvider>(() =>
13  {
14  throw new InvalidOperationException("No VirtualFileProvider set for this microthread.");
15  });
16 
17  public MicroThreadFileProvider(string rootPath) : base(rootPath)
18  {
19  }
20 
21  public override string GetAbsolutePath(string path)
22  {
23  return ThreadLocal.Value.GetAbsolutePath(path);
24  }
25 
26  public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None)
27  {
28  return ThreadLocal.Value.OpenStream(url, mode, access, share, streamFlags);
29  }
30 
31  public override bool FileExists(string url)
32  {
33  return ThreadLocal.Value.FileExists(url);
34  }
35 
36  public override long FileSize(string url)
37  {
38  return ThreadLocal.Value.FileSize(url);
39  }
40  }
41 }
override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share=VirtualFileShare.Read, StreamFlags streamFlags=StreamFlags.None)
Opens a Stream from the specified path. The path.The mode.The access.The process sharing mode...
Abstract base class for IVirtualFileProvider.
VirtualFileShare
File share capabilities, equivalent of System.IO.FileShare.
override long FileSize(string url)
Returns the size of the specified file in bytes The file or directory for which to obtain sizeA long ...
override string GetAbsolutePath(string path)
Gets the absolute path for the specified local path from this provider. The path local to this instan...
VirtualFileAccess
File access equivalent of System.IO.FileAccess.
VirtualFileMode
File mode equivalent of System.IO.FileMode.
override bool FileExists(string url)
Determines whether the specified path points to an existing file. The path.
StreamFlags
Describes the different type of streams.
Definition: StreamFlags.cs:11