-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Allow to view icons from jar files
- Loading branch information
Showing
4 changed files
with
30 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/by/overpass/svgtocomposeintellij/preview/data/VirtualFileExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package by.overpass.svgtocomposeintellij.preview.data | ||
|
||
import com.intellij.openapi.vfs.VirtualFile | ||
import java.io.InputStream | ||
import java.net.JarURLConnection | ||
import java.net.URL | ||
import kotlin.io.path.inputStream | ||
|
||
fun VirtualFile.asInputStream(): InputStream { | ||
return if (fileSystem.protocol == "jar") { | ||
val url = URL("jar:file:$path") | ||
val jarUrlConnection = url.openConnection() as JarURLConnection | ||
jarUrlConnection.inputStream | ||
} else { | ||
toNioPath().inputStream() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters