public DesktopPlatform() { StreamProvider = new FileSystemStreamProvider( "content\\", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "PhotoVs")); FileExtensionReplacement = new Dictionary <string, string> { { ".fx", ".ogl" } }; Audio = new DummyAudio(); }
/// <summary> /// Constructor /// </summary> public EngineSerializer( LoggingContext loggingContext, string engineCacheLocation, FileEnvelopeId?correlationId = null, bool useCompression = false, bool debug = false, bool readOnly = false, FileSystemStreamProvider readStreamProvider = null, ITempCleaner tempDirectoryCleaner = null) { Contract.Requires(loggingContext != null); Contract.Requires(engineCacheLocation != null); Contract.Requires(Path.IsPathRooted(engineCacheLocation)); Contract.Requires(!string.IsNullOrWhiteSpace(engineCacheLocation)); LoggingContext = loggingContext; m_engineCacheLocation = engineCacheLocation; m_debug = debug; m_correlationId = correlationId; m_useCompression = useCompression; m_readStreamProvider = readStreamProvider ?? FileSystemStreamProvider.Default; m_tempDirectoryCleaner = tempDirectoryCleaner; if (!readOnly) { try { FileUtilities.CreateDirectoryWithRetry(engineCacheLocation); } catch (Exception ex) { ExceptionRootCause rootCause = ExceptionUtilities.AnalyzeExceptionRootCause(ex); BuildXL.Tracing.UnexpectedCondition.Log(LoggingContext, ex.ToStringDemystified() + Environment.NewLine + rootCause); throw new BuildXLException("Unable to create engine serializer cache directory: ", ex); } } }
internal string ProcessExecutionLogPath(string path) { if (path != null && path.EndsWith(".zip", System.StringComparison.OrdinalIgnoreCase) && File.Exists(path)) { var zipStreamProvider = new ZipFileSystemStreamProvider(path); StreamProvider = zipStreamProvider; using (var archiveWrapper = zipStreamProvider.OpenArchiveForRead()) { var archive = archiveWrapper.Value; var xlgEntries = archive.Entries.Where(entry => entry.FullName.EndsWith(".xlg", System.StringComparison.OrdinalIgnoreCase)).ToList(); if (xlgEntries.Count != 1) { throw new BuildXLException(I($"Execution log path '{path}' appears to refer to a zip file. Expected to find exactly one entry with extension '.xlg' but found {xlgEntries.Count} ")); } path = Path.Combine(path, xlgEntries[0].FullName.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).TrimStart(Path.DirectorySeparatorChar)); } } else { StreamProvider = FileSystemStreamProvider.Default; if (path != null && Directory.Exists(path)) { var xlgFiles = Directory.GetFiles(path, "*.xlg", SearchOption.TopDirectoryOnly); if (xlgFiles.Length != 1) { throw new BuildXLException(I($"Execution log path '{path}' appears to refer to a directory. Expected to find exactly one file at root with extension '.xlg' but found {xlgFiles.Length} ")); } path = xlgFiles[0]; } } return(path); }
/// <summary> /// Loads the cache graph store in the given directory /// </summary> public static async Task <CachedGraph> LoadAsync(string cachedGraphDirectory, LoggingContext loggingContext, bool preferLoadingEngineCacheInMemory, FileSystemStreamProvider readStreamProvider = null) { // preferLoadingEngineCacheInMemory will be removed after ExecutionLog.cs is updated in OSGTools. var unused = preferLoadingEngineCacheInMemory; CachedGraphLoader loadingGraph = CachedGraphLoader.CreateFromDisk(CancellationToken.None, cachedGraphDirectory, loggingContext, readStreamProvider); var graphId = await loadingGraph.GetOrLoadPipGraphIdAsync(); // Use a the cached graph based on graph id if already in memory if (s_loadedCachedGraphs.TryGetValue(graphId, out var weakCachedGraph) && weakCachedGraph.TryGetTarget(out var cachedGraph)) { return(cachedGraph); } cachedGraph = await loadingGraph.GetOrLoadCachedGraphAsync(); if (cachedGraph?.PipGraph != null) { s_loadedCachedGraphs.AddItem(cachedGraph.PipGraph.GraphId, new WeakReference <CachedGraph>(cachedGraph)); } return(cachedGraph); }
/// <summary> /// Loads a cache graph from a given cached graph directory /// </summary> public static CachedGraphLoader CreateFromDisk(CancellationToken cancellationToken, string cachedGraphDirectory, LoggingContext loggingContext, FileSystemStreamProvider readStreamProvider = null) { var serializer = new EngineSerializer(loggingContext, cachedGraphDirectory, readOnly: true, readStreamProvider: readStreamProvider); return(new CachedGraphLoader(cancellationToken, serializer)); }