/// <summary> /// Creates the virtual files for the metadata in a XML string form. /// </summary> /// <param name="basePath">The base path.</param> /// <param name="xmlString">The XML string.</param> public static void CreateVirtualFiles(ShadowMetaFullPath basePath, string xmlString) { var metaInfo = XmlUtil.FromXml <DataMetaInfo>(xmlString); var torrent = Torrent.Load(metaInfo.TorrentBytes); if (metaInfo.IsSingleFile) { var virtualFile = new VirtualFile() { PhysicalUri = metaInfo.DataUri, FileSize = torrent.Files[0].Length, OnDemand = metaInfo.OnDemand }; var virtualFilePath = basePath.PathString; Logger.WriteLineIf(LogLevel.Verbose, _log_props, string.Format( "Creating virtual file at {0}", virtualFilePath)); IOUtil.PrepareParentDirForPath(virtualFilePath); XmlUtil.WriteXml <VirtualFile>(virtualFile, virtualFilePath); } else { // Create a virtual file for each TorrentFile. foreach (TorrentFile file in torrent.Files) { var pathUri = new Uri(file.Path, UriKind.Relative); var virtualFile = new VirtualFile() { PhysicalUri = UriUtil.CombineUris(metaInfo.DataUri, pathUri), FileSize = file.Length, OnDemand = metaInfo.OnDemand }; var virtualFilePath = UriUtil.CombinePaths(basePath.PathString, pathUri); Logger.WriteLineIf(LogLevel.Verbose, _log_props, string.Format( "Creating virtual file at {0}", virtualFilePath)); IOUtil.PrepareParentDirForPath(virtualFilePath); XmlUtil.WriteXml <VirtualFile>(virtualFile, virtualFilePath); } } }