private T?DoReadRootFile(int identifier, string[] segments) { string path = string.Join("/", segments, 1, segments.Length - 1); Plugin?plugin = bridge?.GetPluginFromToken(identifier); string fullPath = plugin == null ? string.Empty : plugin.GetFullPathIfSafe(PluginFolder.Root, path); if (fullPath.Length == 0) { return(resourceProvider.Status(HttpStatusCode.Forbidden, "File path has to be relative to the plugin root folder.")); } try{ return(resourceProvider.File(File.ReadAllBytes(fullPath), Path.GetExtension(path))); }catch (FileNotFoundException) { return(resourceProvider.Status(HttpStatusCode.NotFound, "File not found.")); }catch (DirectoryNotFoundException) { return(resourceProvider.Status(HttpStatusCode.NotFound, "Directory not found.")); }catch (Exception e) { return(resourceProvider.Status(HttpStatusCode.InternalServerError, e.Message)); } }