mirror of
				https://github.com/packwiz/packwiz-installer.git
				synced 2025-11-04 12:34:31 +01:00 
			
		
		
		
	Add support for loading from file:// URIs
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
package link.infra.packwiz.installer.request
 | 
			
		||||
 | 
			
		||||
import link.infra.packwiz.installer.metadata.SpaceSafeURI
 | 
			
		||||
import link.infra.packwiz.installer.request.handlers.RequestHandlerFile
 | 
			
		||||
import link.infra.packwiz.installer.request.handlers.RequestHandlerGithub
 | 
			
		||||
import link.infra.packwiz.installer.request.handlers.RequestHandlerHTTP
 | 
			
		||||
import okio.Source
 | 
			
		||||
@@ -9,7 +10,8 @@ object HandlerManager {
 | 
			
		||||
 | 
			
		||||
	private val handlers: List<IRequestHandler> = listOf(
 | 
			
		||||
			RequestHandlerGithub(),
 | 
			
		||||
			RequestHandlerHTTP()
 | 
			
		||||
			RequestHandlerHTTP(),
 | 
			
		||||
			RequestHandlerFile()
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	@JvmStatic
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,18 @@
 | 
			
		||||
package link.infra.packwiz.installer.request.handlers
 | 
			
		||||
 | 
			
		||||
import link.infra.packwiz.installer.metadata.SpaceSafeURI
 | 
			
		||||
import link.infra.packwiz.installer.request.IRequestHandler
 | 
			
		||||
import okio.Source
 | 
			
		||||
import okio.source
 | 
			
		||||
import java.nio.file.Paths
 | 
			
		||||
 | 
			
		||||
open class RequestHandlerFile : IRequestHandler {
 | 
			
		||||
	override fun matchesHandler(loc: SpaceSafeURI): Boolean {
 | 
			
		||||
		return "file" == loc.scheme
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	override fun getFileSource(loc: SpaceSafeURI): Source? {
 | 
			
		||||
		val path = Paths.get(loc.toURL().toURI())
 | 
			
		||||
		return path.source()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user