/// <summary> /// Gets all backup files /// </summary> /// <returns>Backup file collection</returns> public virtual IList <string> GetAllBackupFiles() { var path = GetBackupDirectoryPath(); if (!_fileProvider.DirectoryExists(path)) { throw new GSException("Backup directory not exists"); } return(_fileProvider.GetFiles(path, $"*.{GSCommonDefaults.DbBackupFileExtension}") .OrderByDescending(p => _fileProvider.GetLastWriteTime(p)).ToList()); }
static PluginManager() { //we use the default file provider, since the DI isn't initialized yet _fileProvider = CommonHelper.DefaultFileProvider; //get all libraries from /bin/{version}/ directory _baseAppLibraries = _fileProvider.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll").Select(fi => _fileProvider.GetFileName(fi)).ToList(); //get all libraries from base site directory if (!AppDomain.CurrentDomain.BaseDirectory.Equals(Environment.CurrentDirectory, StringComparison.InvariantCultureIgnoreCase)) { _baseAppLibraries.AddRange(_fileProvider.GetFiles(Environment.CurrentDirectory, "*.dll").Select(fi => _fileProvider.GetFileName(fi))); } //get all libraries from refs directory var refsPathName = _fileProvider.Combine(Environment.CurrentDirectory, GSPluginDefaults.RefsPathName); if (_fileProvider.DirectoryExists(refsPathName)) { _baseAppLibraries.AddRange(_fileProvider.GetFiles(refsPathName, "*.dll").Select(fi => _fileProvider.GetFileName(fi))); } }
/// <summary> /// Delete plugin directory from disk storage /// </summary> /// <param name="pluginDescriptor">Plugin descriptor</param> /// <returns>True if plugin directory is deleted, false if not</returns> public static bool DeletePlugin(PluginDescriptor pluginDescriptor) { //no plugin descriptor set if (pluginDescriptor == null) { return(false); } //check whether plugin is installed if (pluginDescriptor.Installed) { return(false); } var directoryName = _fileProvider.GetDirectoryName(pluginDescriptor.OriginalAssemblyFile); if (_fileProvider.DirectoryExists(directoryName)) { _fileProvider.DeleteDirectory(directoryName); } return(true); }
/// <summary> /// Makes sure matching assemblies in the supplied folder are loaded in the app domain. /// </summary> /// <param name="directoryPath"> /// The physical path to a directory containing dlls to load in the app domain. /// </param> protected virtual void LoadMatchingAssemblies(string directoryPath) { var loadedAssemblyNames = new List <string>(); foreach (var a in GetAssemblies()) { loadedAssemblyNames.Add(a.FullName); } if (!_fileProvider.DirectoryExists(directoryPath)) { return; } foreach (var dllPath in _fileProvider.GetFiles(directoryPath, "*.dll")) { try { var an = AssemblyName.GetAssemblyName(dllPath); if (Matches(an.FullName) && !loadedAssemblyNames.Contains(an.FullName)) { App.Load(an); } //old loading stuff //Assembly a = Assembly.ReflectionOnlyLoadFrom(dllPath); //if (Matches(a.FullName) && !loadedAssemblyNames.Contains(a.FullName)) //{ // App.Load(a.FullName); //} } catch (BadImageFormatException ex) { Trace.TraceError(ex.ToString()); } } }
/// <summary> /// Get all available directories as a directory tree /// </summary> /// <param name="type">Type of the file</param> /// <returns>A task that represents the completion of the operation</returns> protected virtual async Task GetDirectoriesAsync(string type) { var rootDirectoryPath = GetFullPath(GetVirtualPath(null)); if (!_fileProvider.DirectoryExists(rootDirectoryPath)) { throw new Exception("Invalid files root directory. Check your configuration."); } var allDirectories = GetDirectories(rootDirectoryPath); allDirectories.Insert(0, rootDirectoryPath); var localPath = GetFullPath(null); await HttpContext.Response.WriteAsync("["); for (var i = 0; i < allDirectories.Count; i++) { var directoryPath = (string)allDirectories[i]; await HttpContext.Response.WriteAsync($"{{\"p\":\"/{directoryPath.Replace(localPath, string.Empty).Replace("\\", "/").TrimStart('/')}\",\"f\":\"{GetFiles(directoryPath, type).Count}\",\"d\":\"{_fileProvider.GetDirectories(directoryPath).Length}\"}}"); if (i < allDirectories.Count - 1) { await HttpContext.Response.WriteAsync(","); } } await HttpContext.Response.WriteAsync("]"); }