Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
VirtualFileSystem.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.Collections.Generic;
5 using System.IO;
6 using System.Linq;
7 using System.Text;
8 using System.Text.RegularExpressions;
9 using System.Threading.Tasks;
10 
11 namespace SiliconStudio.Core.IO
12 {
13  /// <summary>
14  /// Virtual abstraction over a file system.
15  /// It handles access to files, http, packages, path rewrite, etc...
16  /// </summary>
17  public static partial class VirtualFileSystem
18  {
19  public static readonly char DirectorySeparatorChar = '/';
20  public static readonly char AltDirectorySeparatorChar = '\\';
21  public static readonly char[] AllDirectorySeparatorChars = new[] { DirectorySeparatorChar, AltDirectorySeparatorChar };
22 
23  private static readonly Regex pathSplitRegex = new Regex(@"(\\|/)");
24 
25  // As opposed to real Path.GetTempFileName, we don't have a 65536 limit.
26  // This can be achieved by having a fixed random seed.
27  // However, if activated, it would probably test too many files in the same order, if some already exists.
28  private static Random tempFileRandom = new Random(Environment.TickCount);
29 
30  private static Dictionary<string, IVirtualFileProvider> providers = new Dictionary<string, IVirtualFileProvider>();
31 
32  /// <summary>
33  /// The application data file provider.
34  /// </summary>
35  public readonly static IVirtualFileProvider ApplicationData;
36 
37  /// <summary>
38  /// The application database file provider (ObjectId level).
39  /// </summary>
41 
42  /// <summary>
43  /// The application database file provider (Index level).
44  /// </summary>
45  public readonly static IVirtualFileProvider ApplicationDatabase;
46 
47  /// <summary>
48  /// The application cache folder.
49  /// </summary>
50  public readonly static IVirtualFileProvider ApplicationCache;
51 
52  /// <summary>
53  /// The application user roaming folder. Included in backup.
54  /// </summary>
55  public readonly static IVirtualFileProvider ApplicationRoaming;
56 
57  /// <summary>
58  /// The application user local folder. Included in backup.
59  /// </summary>
60  public readonly static IVirtualFileProvider ApplicationLocal;
61 
62  /// <summary>
63  /// The application temporary data provider.
64  /// </summary>
66 
67  /// <summary>
68  /// The application binary folder.
69  /// </summary>
70  public readonly static IVirtualFileProvider ApplicationBinary;
71 
72  /// <summary>
73  /// The whole host file system. This should be used only in tools.
74  /// </summary>
75  public static readonly DriveFileProvider Drive;
76 
77  /// <summary>
78  /// Initializes a new instance of the <see cref="VirtualFileSystem" /> class.
79  /// </summary>
80  static VirtualFileSystem()
81  {
82  Platform.IsVirtualFileSystemInitialized = true;
83  // TODO: find a better solution to customize the ApplicationDataDirectory, now we're very limited due to the initialization from a static constructor
84 #if SILICONSTUDIO_PLATFORM_ANDROID
85  ApplicationData = new ZipFileSystemProvider("/data", PlatformAndroid.Context.ApplicationInfo.SourceDir);
86 #else
87  ApplicationData = new FileSystemProvider("/data", Path.Combine(Platform.ApplicationDataDirectory, Platform.ApplicationDataSubDirectory));
88 #endif
89  ApplicationCache = new FileSystemProvider("/cache", Platform.ApplicationCacheDirectory);
90 #if SILICONSTUDIO_PLATFORM_IOS
91  // On iOS, we don't want cache folder to be cleared by the OS.
92  ((FileSystemProvider)ApplicationCache).AutoSetSkipBackupAttribute = true;
93 #endif
94  ApplicationRoaming = new FileSystemProvider("/roaming", Platform.ApplicationRoamingDirectory);
95  ApplicationLocal = new FileSystemProvider("/local", Platform.ApplicationLocalDirectory);
96  ApplicationTemporary = new FileSystemProvider("/tmp", Platform.ApplicationTemporaryDirectory);
97  ApplicationBinary = new FileSystemProvider("/binary", Platform.ApplicationBinaryDirectory);
99  }
100 
101  /// <summary>
102  /// Gets the registered providers.
103  /// </summary>
104  /// <value>The providers.</value>
105  public static IEnumerable<IVirtualFileProvider> Providers
106  {
107  get
108  {
109  return providers.Values;
110  }
111  }
112 
113  /// <summary>
114  /// Registers the specified virtual file provider at the specified mount location.
115  /// </summary>
116  /// <param name="provider">The provider.</param>
117  public static void RegisterProvider(IVirtualFileProvider provider)
118  {
119  if (provider.RootPath != null)
120  {
121  if (providers.ContainsKey(provider.RootPath))
122  throw new InvalidOperationException(string.Format("A Virtual File Provider with the root path \"{0}\" already exists.", provider.RootPath));
123 
124  providers.Add(provider.RootPath, provider);
125  }
126  }
127 
128  /// <summary>
129  /// Unregisters the specified virtual file provider.
130  /// </summary>
131  /// <param name="provider">The provider.</param>
132  /// <param name="dispose">Indicate that the provider should be disposed, if it inherits from IDisposable interface.</param>
133  public static void UnregisterProvider(IVirtualFileProvider provider, bool dispose = true)
134  {
135  var mountPoints = providers.Where(x => x.Value == provider).ToArray();
136  foreach (var mountPoint in mountPoints)
137  providers.Remove(mountPoint.Key);
138 
139  if (dispose)
140  {
141  var disposable = provider as IDisposable;
142  if (disposable != null)
143  disposable.Dispose();
144  }
145  }
146 
147  /// <summary>
148  /// Mounts the specified path in the specified virtual file mount point.
149  /// </summary>
150  /// <param name="mountPoint">The mount point in the VFS.</param>
151  /// <param name="path">The directory path.</param>
152  public static IVirtualFileProvider MountFileSystem(string mountPoint, string path)
153  {
154  return new FileSystemProvider(mountPoint, path);
155  }
156 
157  /// <summary>
158  /// Mounts or remounts the specified path in the specified virtual file mount point.
159  /// </summary>
160  /// <param name="mountPoint">The mount point in the VFS.</param>
161  /// <param name="path">The directory path.</param>
162  public static IVirtualFileProvider RemountFileSystem(string mountPoint, string path)
163  {
164  // Ensure mount point is terminated with a /
165  if (mountPoint[mountPoint.Length - 1] != VirtualFileSystem.DirectorySeparatorChar)
166  mountPoint += VirtualFileSystem.DirectorySeparatorChar;
167 
168  // Find existing provider
169  var provider = providers.FirstOrDefault(x => x.Key == mountPoint);
170  if (provider.Value != null)
171  {
172  ((FileSystemProvider)provider.Value).ChangeBasePath(path);
173  return provider.Value;
174  }
175 
176  // Otherwise create new one
177  return new FileSystemProvider(mountPoint, path);
178  }
179 
180  /// <summary>
181  /// Checks the existence of a file.
182  /// </summary>
183  /// <param name="path">The path of the file to check.</param>
184  /// <returns></returns>
185  public static bool FileExists(string path)
186  {
187  if (path == null) throw new ArgumentNullException("path");
188  var result = ResolveProviderUnsafe(path, true);
189  if (result.Provider == null)
190  return false;
191 
192  return result.Provider.FileExists(result.Path);
193  }
194 
195  /// <summary>
196  /// Checks the existence of a directory.
197  /// </summary>
198  /// <param name="path">The path of the directory to check.</param>
199  /// <returns></returns>
200  public static bool DirectoryExists(string path)
201  {
202  if (path == null) throw new ArgumentNullException("path");
203  var result = ResolveProviderUnsafe(path, true);
204  if (result.Provider == null)
205  return false;
206 
207  return result.Provider.DirectoryExists(result.Path);
208  }
209 
210  public static void FileDelete(string path)
211  {
212  var result = ResolveProvider(path, true);
213  result.Provider.FileDelete(result.Path);
214  }
215 
216  public static void FileMove(string sourcePath, string destinationPath)
217  {
218  ResolveProviderResult sourceResult = ResolveProvider(sourcePath, true);
219  ResolveProviderResult destinationResult = ResolveProvider(destinationPath, true);
220 
221  if (sourceResult.Provider == destinationResult.Provider)
222  {
223  sourceResult.Provider.FileMove(sourceResult.Path, destinationResult.Path);
224  }
225  else
226  {
227  sourceResult.Provider.FileMove(sourceResult.Path, destinationResult.Provider, destinationResult.Path);
228  }
229  }
230 
231  public static long FileSize(string path)
232  {
233  var result = ResolveProvider(path, true);
234  return result.Provider.FileSize(result.Path);
235  }
236 
237  public static DateTime GetLastWriteTime(string path)
238  {
239  var result = ResolveProvider(path, true);
240  return result.Provider.GetLastWriteTime(result.Path);
241  }
242 
243 
244  public static Task<bool> FileExistsAsync(string path)
245  {
246  return Task<bool>.Factory.StartNew(() => FileExists(path));
247  }
248 
249  /// <summary>
250  /// Creates all directories so that path exists.
251  /// </summary>
252  /// <param name="path">The path.</param>
253  public static void CreateDirectory(string path)
254  {
255  var resolveProviderResult = ResolveProvider(path, true);
256  resolveProviderResult.Provider.CreateDirectory(resolveProviderResult.Path);
257  }
258 
259  /// <summary>
260  /// Opens the stream from a given path.
261  /// </summary>
262  /// <param name="path">The path.</param>
263  /// <param name="mode">The stream opening mode (append, open, create, etc...).</param>
264  /// <param name="access">The stream access.</param>
265  /// <param name="share">The stream share mode.</param>
266  /// <returns></returns>
267  public static Stream OpenStream(string path, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read)
268  {
269  var resolveProviderResult = ResolveProvider(path, false);
270  return resolveProviderResult.Provider.OpenStream(resolveProviderResult.Path, mode, access, share);
271  }
272 
273  /// <summary>
274  /// Opens the stream from a given path.
275  /// </summary>
276  /// <param name="path">The path.</param>
277  /// <param name="mode">The stream opening mode (append, open, create, etc...).</param>
278  /// <param name="access">The stream access.</param>
279  /// <param name="share">The stream share mode.</param>
280  /// <param name="provider">The provider used to load the stream.</param>
281  /// <returns>The stream.</returns>
282  public static Stream OpenStream(string path, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share, out IVirtualFileProvider provider)
283  {
284  var resolveProviderResult = ResolveProvider(path, false);
285  provider = resolveProviderResult.Provider;
286  return provider.OpenStream(resolveProviderResult.Path, mode, access, share);
287  }
288 
290  {
291  return Task<Stream>.Factory.StartNew(() => OpenStream(path, mode, access, share));
292  }
293 
294  /// <summary>
295  /// Gets the absolute path (system dependent) for the specified path in the context of the virtual file system.
296  /// </summary>
297  /// <param name="path">The path local to the virtual file system.</param>
298  /// <returns>An absolute path (system dependent .i.e C:\Path\To\Your\File.x).</returns>
299  public static string GetAbsolutePath(string path)
300  {
301  var resolveProviderResult = ResolveProvider(path, true);
302  return resolveProviderResult.Provider.GetAbsolutePath(resolveProviderResult.Path);
303  }
304 
305  /// <summary>
306  /// Resolves the path.
307  /// </summary>
308  /// <param name="path">The path.</param>
309  /// <returns></returns>
310  public static string Resolvepath(string path)
311  {
312  var resolveProviderResult = ResolveProvider(path, false);
313 
314  var sb = new StringBuilder();
315  if (resolveProviderResult.Provider.RootPath != ".")
316  {
317  sb.Append(resolveProviderResult.Provider.RootPath);
318  sb.Append("/");
319  }
320  sb.Append(resolveProviderResult.Path);
321 
322  return sb.ToString();
323  }
324 
325  /// <summary>
326  /// Lists the files matching a pattern in a specified directory.
327  /// </summary>
328  /// <param name="path">The path.</param>
329  /// <param name="searchPattern">The search pattern.</param>
330  /// <param name="searchOption">The search option.</param>
331  /// <returns></returns>
332  public static Task<string[]> ListFiles(string path, string searchPattern, VirtualSearchOption searchOption)
333  {
334  var resolveProviderResult = ResolveProvider(path, true);
335  return Task.Factory.StartNew(() => resolveProviderResult.Provider.ListFiles(resolveProviderResult.Path, searchPattern, searchOption)
336  .Select(x => resolveProviderResult.Provider.RootPath + x).ToArray());
337  }
338 
339  /// <summary>
340  /// Creates a temporary zero-byte file and returns its full path.
341  /// </summary>
342  /// <returns>The full path of the created temporary file.</returns>
343  public static string GetTempFileName()
344  {
345  int tentatives = 0;
346  Stream stream = null;
347  string filename;
348  do
349  {
350  filename = "pdx" + ((tempFileRandom.Next() + 1)).ToString("x") + ".tmp";
351  try
352  {
353  stream = ApplicationTemporary.OpenStream(filename, VirtualFileMode.CreateNew, VirtualFileAccess.ReadWrite);
354  }
355  catch (IOException)
356  {
357  // No more than 65536 files
358  if (tentatives++ > 0x10000)
359  throw;
360  }
361  } while (stream == null);
362  stream.Dispose();
363 
364  return ApplicationTemporary.RootPath + "/" + filename;
365  }
366 
367  public static string BuildPath(string path, string relativePath)
368  {
369  return path.Substring(0, LastIndexOfDirectorySeparator(path) + 1) + relativePath;
370  }
371 
372  /// <summary>
373  /// Returns the path with its .. or . parts simplified.
374  /// </summary>
375  /// <param name="path">The path.</param>
376  /// <returns></returns>
377  public static string ResolveAbsolutePath(string path)
378  {
379  if (!path.Contains(DirectorySeparatorChar + ".."))
380  return path;
381 
382  var pathElements = pathSplitRegex.Split(path).ToList();
383 
384  // Remove duplicate directory separators
385  for (int i = 0; i < pathElements.Count; ++i)
386  {
387  if (pathElements[i].Length > 1 && (pathElements[i][0] == '/' || pathElements[i][0] == '\\'))
388  pathElements[i] = pathElements[i][0].ToString();
389  }
390 
391  for (int i = 0; i < pathElements.Count; ++i)
392  {
393  if (pathElements[i] == "..")
394  {
395  // Remove .. and the item preceding that, if any
396  if (i >= 3 && (pathElements[i - 1] == "/" || pathElements[i - 1] == "\\"))
397  {
398  pathElements.RemoveRange(i - 3, 4);
399  i -= 4;
400  }
401  }
402  else if (pathElements[i] == ".")
403  {
404  if (i >= 1 && (pathElements[i - 1] == "/" || pathElements[i - 1] == "\\"))
405  {
406  pathElements.RemoveRange(i - 1, 2);
407  i -= 2;
408  }
409  else if (i + 1 < pathElements.Count && (pathElements[i + 1] == "/" || pathElements[i + 1] == "\\"))
410  {
411  pathElements.RemoveRange(i, 2);
412  --i;
413  }
414  }
415  }
416 
417  return string.Join(string.Empty, pathElements);
418  }
419 
420  /// <summary>
421  /// Combines the specified paths.
422  /// Similiar to <see cref="System.IO.Path.Combine(string, string)"/>.
423  /// </summary>
424  /// <param name="path1">The path1.</param>
425  /// <param name="path2">The path2.</param>
426  /// <returns></returns>
427  public static string Combine(string path1, string path2)
428  {
429  if (path1.Length == 0)
430  return path2;
431  if (path2.Length == 0)
432  return path1;
433 
434  var lastPath1 = path1[path1.Length - 1];
435  if (lastPath1 != DirectorySeparatorChar && lastPath1 != AltDirectorySeparatorChar)
436  return path1 + DirectorySeparatorChar + path2;
437 
438  return path1 + path2;
439  }
440 
441  /// <summary>
442  /// Gets the parent folder.
443  /// </summary>
444  /// <param name="path">The path.</param>
445  /// <returns></returns>
446  /// <exception cref="System.ArgumentNullException">path</exception>
447  /// <exception cref="System.ArgumentException">path doesn't contain a /;path</exception>
448  public static string GetParentFolder(string path)
449  {
450  if (path == null)
451  throw new ArgumentNullException("path");
452 
453  var lastSlashIndex = LastIndexOfDirectorySeparator(path);
454  if (lastSlashIndex == -1)
455  throw new ArgumentException(string.Format("path [{0}] doesn't contain a /", path), "path");
456 
457  return path.Substring(0, lastSlashIndex);
458  }
459 
460  /// <summary>
461  /// Gets the file's name with its extension ("/path/to/file/fileName.ext"->"fileName.ext")
462  /// </summary>
463  /// <param name="path">path containing file's path and name </param>
464  /// <returns>The name of the file with its extension</returns>
465  public static string GetFileName(string path)
466  {
467  if (path == null)
468  throw new ArgumentNullException("path");
469 
470  var lastSlashIndex = LastIndexOfDirectorySeparator(path);
471 
472  return path.Substring(lastSlashIndex + 1);
473  }
474 
475  /// <summary>
476  /// Creates the relative path that can access to <see cref="target"/> from <see cref="sourcePath"/>.
477  /// </summary>
478  /// <param name="target">The target.</param>
479  /// <param name="sourcePath">The source path.</param>
480  /// <returns></returns>
481  public static string CreateRelativePath(string target, string sourcePath)
482  {
483  var targetDirectories = target.Split(AllDirectorySeparatorChars, StringSplitOptions.RemoveEmptyEntries);
484  var sourceDirectories = sourcePath.Split(AllDirectorySeparatorChars, StringSplitOptions.RemoveEmptyEntries);
485 
486  // Find common root
487  int length = Math.Min(targetDirectories.Length, sourceDirectories.Length);
488  int commonRoot;
489  for (commonRoot = 0; commonRoot < length; ++commonRoot)
490  {
491  if (targetDirectories[commonRoot] != sourceDirectories[commonRoot])
492  break;
493  }
494 
495  var result = new StringBuilder();
496 
497  // Append .. for each path only in source
498  for (int i = commonRoot; i < sourceDirectories.Length; ++i)
499  {
500  result.Append(".." + DirectorySeparatorChar);
501  }
502 
503  // Append path in destination
504  for (int i = commonRoot; i < targetDirectories.Length; ++i)
505  {
506  result.Append(targetDirectories[i]);
507  if (i < targetDirectories.Length - 1)
508  result.Append(DirectorySeparatorChar);
509  }
510 
511  return result.ToString();
512  }
513 
514  /// <summary>
515  /// Resolves the virtual file provider for a given path.
516  /// </summary>
517  /// <param name="path">The path.</param>
518  /// <param name="resolveTop">if set to <c>true</c> [resolve top].</param>
519  /// <returns></returns>
520  /// <exception cref="System.InvalidOperationException">path cannot be resolved to a provider.</exception>
521  public static ResolveProviderResult ResolveProvider(string path, bool resolveTop)
522  {
523  if (path == null) throw new ArgumentNullException("path");
524  var result = ResolveProviderUnsafe(path, resolveTop);
525  if (result.Provider == null)
526  throw new InvalidOperationException(string.Format("path [{0}] cannot be resolved to a provider.", path));
527  return result;
528  }
529 
530  private static int LastIndexOfDirectorySeparator(string path)
531  {
532  int length = path.Length;
533  while (--length >= 0)
534  {
535  var c = path[length];
536  if (c == DirectorySeparatorChar || c == AltDirectorySeparatorChar)
537  {
538  return length;
539  }
540  }
541  return -1;
542  }
543 
544  public static ResolveProviderResult ResolveProviderUnsafe(string path, bool resolveTop)
545  {
546  // Slow path for path using \ instead of /
547  if (path.Contains(AltDirectorySeparatorChar))
548  {
549  path = path.Replace(AltDirectorySeparatorChar, DirectorySeparatorChar);
550  }
551 
552  // Resolve using providers at every level of the path (deep first)
553  // i.e. provider for path /a/b/c/file will be searched in the following order: /a/b/c/ then /a/b/ then /a/.
554  for (int i = path.Length - 1; i >= 0; --i)
555  {
556  var pathChar = path[i];
557  var isResolvingTop = (i == path.Length - 1 && resolveTop);
558  if (!isResolvingTop && pathChar != DirectorySeparatorChar)
559  {
560  continue;
561  }
562 
563  IVirtualFileProvider provider;
564  string providerpath = isResolvingTop && pathChar != DirectorySeparatorChar ? new StringBuilder(path.Length + 1).Append(path).Append(DirectorySeparatorChar).ToString() : (i + 1) == path.Length ? path : path.Substring(0, i + 1);
565 
566  if (providers.TryGetValue(providerpath, out provider))
567  {
568  // If resolving top, we want the / at the end of "path" if it wasn't there already (should be in providerpath).
569  if (isResolvingTop)
570  path = providerpath;
571  return new ResolveProviderResult { Provider = provider, Path = path.Substring(providerpath.Length) };
572  }
573  }
574  return new ResolveProviderResult();
575  }
576 
577  public struct ResolveProviderResult
578  {
580  public string Path;
581  }
582  }
583 }
A virtual file provider, that can returns a Stream for a given path.
Virtual abstraction over a file system. It handles access to files, http, packages, path rewrite, etc...
static IVirtualFileProvider MountFileSystem(string mountPoint, string path)
Mounts the specified path in the specified virtual file mount point.
static readonly IVirtualFileProvider ApplicationTemporary
The application temporary data provider.
static string ApplicationDataSubDirectory
The (optional) application data subdirectory. If not null or empty, /data will be mounted on Applicat...
Definition: Platform.cs:91
static readonly IVirtualFileProvider ApplicationRoaming
The application user roaming folder. Included in backup.
static readonly string ApplicationLocalDirectory
The application local directory, where user can write local data (included in backup).
Definition: Platform.cs:68
A file system implementation for IVirtualFileProvider.
static ResolveProviderResult ResolveProviderUnsafe(string path, bool resolveTop)
static void FileMove(string sourcePath, string destinationPath)
static ResolveProviderResult ResolveProvider(string path, bool resolveTop)
Resolves the virtual file provider for a given path.
static bool FileExists(string path)
Checks the existence of a file.
VirtualFileShare
File share capabilities, equivalent of System.IO.FileShare.
static readonly string ApplicationBinaryDirectory
The application directory, where assemblies are deployed. It could be read-only on some platforms...
Definition: Platform.cs:106
static string Resolvepath(string path)
Resolves the path.
static readonly IVirtualFileProvider ApplicationBinary
The application binary folder.
static readonly string ApplicationRoamingDirectory
The application roaming directory, where user can write roaming data (included in backup)...
Definition: Platform.cs:73
Exposes the whole file system through folder similar to Cygwin. As an example, "/c/Program Files/Test...
static Task< Stream > OpenStreamAsync(string path, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share=VirtualFileShare.Read)
static bool DirectoryExists(string path)
Checks the existence of a directory.
static string GetParentFolder(string path)
Gets the parent folder.
static string GetTempFileName()
Creates a temporary zero-byte file and returns its full path.
static readonly IVirtualFileProvider ApplicationData
The application data file provider.
static IVirtualFileProvider ApplicationObjectDatabase
The application database file provider (ObjectId level).
static string Combine(string path1, string path2)
Combines the specified paths. Similiar to System.IO.Path.Combine(string, string). ...
VirtualFileAccess
File access equivalent of System.IO.FileAccess.
static string CreateRelativePath(string target, string sourcePath)
Creates the relative path that can access to target from sourcePath.
VirtualFileMode
File mode equivalent of System.IO.FileMode.
static string BuildPath(string path, string relativePath)
static Stream OpenStream(string path, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share=VirtualFileShare.Read)
Opens the stream from a given path.
static Stream OpenStream(string path, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share, out IVirtualFileProvider provider)
Opens the stream from a given path.
static readonly string ApplicationCacheDirectory
The application cache directory, where user can write data that won't be backup.
Definition: Platform.cs:78
static void UnregisterProvider(IVirtualFileProvider provider, bool dispose=true)
Unregisters the specified virtual file provider.
static string GetFileName(string path)
Gets the file's name with its extension ("/path/to/file/fileName.ext"->"fileName.ext") ...
static void CreateDirectory(string path)
Creates all directories so that path exists.
Platform specific queries and functions.
Definition: Platform.cs:15
static string ResolveAbsolutePath(string path)
Returns the path with its .. or . parts simplified.
static string GetAbsolutePath(string path)
Gets the absolute path (system dependent) for the specified path in the context of the virtual file s...
static readonly IVirtualFileProvider ApplicationDatabase
The application database file provider (Index level).
static Task< string[]> ListFiles(string path, string searchPattern, VirtualSearchOption searchOption)
Lists the files matching a pattern in a specified directory.
static DateTime GetLastWriteTime(string path)
static readonly DriveFileProvider Drive
The whole host file system. This should be used only in tools.
static readonly IVirtualFileProvider ApplicationLocal
The application user local folder. Included in backup.
static string ApplicationTemporaryDirectory
The Application temporary directory.
Definition: Platform.cs:63
static Task< bool > FileExistsAsync(string path)
static readonly string ApplicationDataDirectory
The application data directory, where data is deployed. It could be read-only on some platforms...
Definition: Platform.cs:84
string RootPath
Gets or sets the root path of this provider. See remarks.
static IVirtualFileProvider RemountFileSystem(string mountPoint, string path)
Mounts or remounts the specified path in the specified virtual file mount point.
static void RegisterProvider(IVirtualFileProvider provider)
Registers the specified virtual file provider at the specified mount location.
static readonly IVirtualFileProvider ApplicationCache
The application cache folder.