4 using System.Globalization;
7 namespace SiliconStudio.Core.IO
14 #if SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME
15 public static readonly
char VolumeSeparatorChar =
':';
16 public static readonly
char DirectorySeparatorChar =
'\\';
18 public static readonly
char VolumeSeparatorChar = Path.VolumeSeparatorChar;
19 public static readonly
char DirectorySeparatorChar = Path.DirectorySeparatorChar;
21 public static readonly
char AltDirectorySeparatorChar = AltDirectorySeparatorChar ==
'/' ?
'\\' :
'/';
26 private string localBasePath;
35 ChangeBasePath(localBasePath);
40 localBasePath = basePath;
42 if (localBasePath != null)
43 localBasePath = localBasePath.Replace(AltDirectorySeparatorChar, DirectorySeparatorChar);
47 localBasePath = localBasePath + DirectorySeparatorChar;
52 if (localBasePath == null)
54 return localBasePath + url.Replace(VirtualFileSystem.DirectorySeparatorChar, DirectorySeparatorChar);
59 if (localBasePath == null)
62 if (!path.StartsWith(localBasePath, StringComparison.OrdinalIgnoreCase))
63 throw new InvalidOperationException(
"Trying to convert back a path that is not in this file system provider.");
70 var path = ConvertUrlToFullPath(url);
71 return NativeFile.DirectoryExists(path);
77 var path = ConvertUrlToFullPath(url);
80 NativeFile.DirectoryCreate(path);
84 throw new InvalidOperationException(
"Unable to create directory [{0}]".ToFormat(path), ex);
91 return NativeFile.FileExists(ConvertUrlToFullPath(url));
96 return NativeFile.FileSize(ConvertUrlToFullPath(url));
102 NativeFile.FileDelete(ConvertUrlToFullPath(url));
Virtual abstraction over a file system. It handles access to files, http, packages, path rewrite, etc...
FileSystemProvider(string rootPath, string localBasePath)
Initializes a new instance of the FileSystemProvider class with the given base path.
Abstract base class for IVirtualFileProvider.
A file system implementation for IVirtualFileProvider.
static readonly char DirectorySeparatorChar
void ChangeBasePath(string basePath)
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 void CreateDirectory(string url)
Creates all directories so that url exists. The URL.
virtual string ConvertFullPathToUrl(string path)
virtual string ConvertUrlToFullPath(string url)
override bool FileExists(string url)
Determines whether the specified path points to an existing file. The path.
override bool DirectoryExists(string url)
Determines whether the specified path points to an existing directory.
override void FileDelete(string url)
Deletes the specified file. The URL.