/// <summary> /// </summary> /// <param name="filesystem"></param> /// <param name="path"></param> public PluginArchiveLoader(IFilesystem filesystem, string path) { _filesystem = filesystem; _plugins = new Dictionary <PluginId, PluginGroup>(); try { // TODO: How would we make this truly async? Currently the app has to block until all plugins are loaded wich is sad var files = filesystem.EnumerateFiles(path, string.Format("*.{0}", PluginArchive.PluginExtension)) .Result; foreach (var pluginPath in files) { TryOpenPlugin(pluginPath); } foreach (var plugin in _plugins.Values) { plugin.Load(); } } catch (DirectoryNotFoundException e) { Log.WarnFormat("Unable to find plugins in '{0}': {1}", path, e); } catch (Exception e) { Log.ErrorFormat("Unable to find plugins in '{0}': {1}", path, e); } }
private IReadOnlyList <string> EnumerateFilesPrivate(string wildcardPattern) { var path = Path.GetDirectoryName(wildcardPattern); var fileName = Path.GetFileName(wildcardPattern); var absolutePath = Core.Paths.NormalizeAndEvaluate(path, _filesystem.CurrentDirectory); var files = _filesystem.EnumerateFiles(absolutePath, fileName, SearchOption.TopDirectoryOnly, tolerateNonExistantPath: true); return(files); }
public Task DeleteFilesAsync(string filePathPattern) { var path = Path.GetDirectoryName(filePathPattern); var fileName = Path.GetFileName(filePathPattern); var absolutePath = NormalizeAndEvaluate(path); var files = _filesystem.EnumerateFiles(absolutePath, fileName, SearchOption.TopDirectoryOnly, tolerateNonExistantPath: true); foreach (var file in files) { DeleteFile(file); } return(Task.FromResult(42)); }
private void TryLoadPluginsFrom(IFilesystem filesystem, string path) { try { var files = filesystem.EnumerateFiles(path, string.Format("*.{0}", PluginArchive.PluginExtension)); foreach (var pluginPath in files) { TryOpenPlugin(pluginPath); } } catch (DirectoryNotFoundException e) { Log.WarnFormat("Unable to find plugins in '{0}': {1}", path, e); } catch (Exception e) { Log.ErrorFormat("Unable to find plugins in '{0}': {1}", path, e); } }
public Task <IReadOnlyList <string> > EnumerateSnapshots() { var pattern = string.Format("*.{0}", Constants.SnapshotExtension); return(_filesystem.EnumerateFiles(Constants.SnapshotDirectory, pattern)); }